You shouldn't be polluting `$rootScope` inside angular application. Because `$rootScope` is topmost `root` of application. If you define any variable over it, it will available on any child scope. When it comes to variable sharing among-est different components of Angular, you should consider using service/factory. They are singleton object which will be available throughout the application.
app.service('sharedData', sharedDataService)
function sharedDataService(){
var self = this;
self.getName = getName;
self.setName = setName;
function setName(name) {
self.name = name;
}
functName(nam = namee) {
return self.name;
}
}
$scope.local = sharedData.getName();
sharedData.setName('anonymous')
$scope.getName = sharedData.getName;
You could use `{{getName()}}`