How do you share data between controllers?
Create an AngularJS service that will hold the data and inject it inside of the controllers.
Using a service is the cleanest, fastest and easiest way to test.
However, there are couple of other ways to implement data sharing between controllers, like:
controllerAs, etc. to directly access the controllers
– Using the
$rootScope to add the data on (not a good practice)
The methods above are all correct, but are not the most efficient and easy to test.
Here is a good video explanation on egghead.io.