How can create separate controller file for each view?

Hi All,

How can i dynamic load controller for each view?? Is this possible using ionic/ angularjs?

Please let me know if any confusion .

Thanks.

You can define the controller to be used per state when you define the state, you can also use ngController directive to use another controller in a part of your view.

https://docs.angularjs.org/api/ng/directive/ngController

Thanks…

But how can i do using requredjs.


If there is a 30-40 view for this i want to load different-different controller and when i open any particular view it should load that page controller not other controller js.

Can i create like that??

Please let me know if any confusion .

:slight_smile: i try same thing…But route is not working proper…
Can you help me in route ??

They are using Angular.js own $route, you need to just change those bits to use ui-routers equivalent since ionic uses ui-router.