开发者

Access a variable in a controller from another controller

开发者 https://www.devze.com 2023-01-03 01:49 出处:网络
I am looking for a way to access some variables which I assigned values in one controller(say: controller A) in another controller(say: controller B). One of the controllers contains my main project b

I am looking for a way to access some variables which I assigned values in one controller(say: controller A) in another controller(say: controller B). One of the controllers contains my main project but the other is where I implemented 'Date Picker'. i 开发者_运维技巧want to move the date from the Date Picker controller to my App controller.


You cannot as the other controller does not/may not live during the execution of the correct controller. Even if it was possible logically one controller have nothing in common - IMHO breaking modularity of MVC pattern.

Refactor code to lib/, ApplicationController or some model (separate or divided as method) depending of application.

PS. I'm not quite sure what you mean by "Data Picker" but it sounds like something that should be implemented in model(s).

0

精彩评论

暂无评论...
验证码 换一张
取 消