How do I use $rootScope in Angular to store variables?

Variables set at the root-scope are available to the controller scope via prototypical inheritance. Here is a modified version of @Nitish’s demo that shows the relationship a bit clearer: http://jsfiddle.net/TmPk5/6/ Notice that the rootScope’s variable is set when the module initializes, and then each of the inherited scope’s get their own copy which can be … Read more

AngularJS: How can I pass variables between controllers?

One way to share variables across multiple controllers is to create a service and inject it in any controller where you want to use it. Simple service example: angular.module(‘myApp’, []) .service(‘sharedProperties’, function () { var property = ‘First’; return { getProperty: function () { return property; }, setProperty: function(value) { property = value; } }; … Read more