简体   繁体   中英

Call a controller method from a model class

I have a simple question. Is it possible to call a controller method from a model? I can't seem to figure it out if it is possible. Should I just be returning something from the model to the controller rather than trying to call a method directly? Thanks, Pat

Should I just be returning something from the model to the controller rather than trying to call a method directly

Indeed, that's the correct approach. I'm sure there must me some ways to call some methods from the controller, but you shouldn't use them. A model must encapsulate all the logic, business and alike, of the domain problem you are working with. A controller only needs to send and receive messages between models, and back to the views.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM