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:
– Using events
– Using $parent
, nextSibling
, 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.