Best practice for app controller


#1

I want to make an app which will be having 6 pages. I’m confused between using separate controller for each page or single controller controls entire app.

I’m confused with transferring data between two controllers(currently I tried with different controllers for pages)


#2

I would recommend each page having a separate controller. The easiest way to transfer data between controllers is via services, http://stackoverflow.com/a/20181543/3596698 .


#3

Take my course on angularjs, you want to get up to at least the section called “Communicating between controllers using Services” - in there I cover why you should use services and how they can be used to… well… communicate between controllers.

You can find it from my website https://codecraftpro.com


#4

Have a look at the Angular Style Guide for best practices.


#5

hehehe … Yeah … I’m fairly new to AngularJS (like 2 weeks) and I also came to my conclussion that communication between controllers via services is very handy.