Every application has a single root scope. All other scopes are descendant scopes of the root scope. Scopes provide separation between the model and the view, via a mechanism for watching the model for changes. They also provide an event emission/broadcast and subscription facility. See the developer guide on scopes.
Questions tagged [angularjs-rootscope]
152 questions
1
vote
0 answers
Convert this $rootScope to factory used in http basic authentication angularjs
I am using this example to build a HTTP Basic authentication app with angularjs.
http://jasonwatmore.com/post/2014/05/26/AngularJS-Basic-HTTP-Authentication-Example.aspx
The writer uses $rootScope to store username and password. I would like to…

guagay_wk
- 26,337
- 54
- 186
- 295
1
vote
2 answers
$rootScope is undefined in controller
I am getting very strange issue in angular. I have defined $rootScope.user_info in run method. But when i am fetching the root scope in controller, sometimes i am getting undefined method $rootScope.user_info in controller. any idea why this is…

Ankita Agrawal
- 422
- 5
- 20
1
vote
0 answers
Error: [filter:notarray] Expected array but received an object
Hi I am trying to create a basic global search which will filter results on the pages depending on which view (controller) is present.
Search controller:
1
vote
1 answer
Adding templateUrl dynamically while setting $routeProvider $ angular.config
I am angular newbie.I would like to achieve following code...
$routeProvider.when('/view', {templateUrl: 'ViewSwitcher?pageId='+$rootSope.pageId+'&userId='+$rootSope..userId+'&token='+$rootScope.token, controller: ''});
ViewSwitcher is a servelet…

AKRICK
- 55
- 1
- 7
1
vote
2 answers
Run a function every time an Angular controller is loaded
I want to run a function every time any Angular controller is loaded.
The best way I have found is to attach this handler in the first controller loaded on my site:
$rootScope.$on('$stateChangeSuccess',
function(event, toState, toParams,…

Don P
- 60,113
- 114
- 300
- 432
1
vote
3 answers
$rootScope.$broadcast on $rootScope.$on: RangeError: Maximum call stack size exceeded
I want to define page title in angular like this :
a standard PageController :
angular.module('admin').controller('AdminController',
function($scope) {
// emit an event to rootscope
…

Rémi Becheras
- 14,902
- 14
- 51
- 81
1
vote
1 answer
Custom expiration date directive throwing rootScope digest error
I have 2 input fields that need to get validated after both fields have been entered. It's a credit card expiration date, so theres a month and year. I'm using a third-party service to actually do the validation.
Therefore, I setup 3 directives:…

cusejuice
- 10,285
- 26
- 90
- 145
1
vote
0 answers
ionic app.run deviceready rootscoop variable not working
In my ionic app I have the app.run function and a device ready function inside it:
app.run(function($rootScope, $ionicPlatform, $cordovaPush) {
document.addEventListener("deviceready", function(){
}, false);
})
When I declare a rootScope…

user1242574
- 1,257
- 3
- 12
- 29
1
vote
1 answer
Is there something similar to angular $rootScope in Polymer.dart?
I know that in angular exists something called $rootScope. This one contains variables that are going to be shared by all the controllers. I'm looking for something similar for Polymer, so that I don't need to pass a parent variable as attributes…

Luis Vargas
- 2,466
- 2
- 15
- 32
0
votes
1 answer
Angular JS 1.x - Can't pass $rootScope variable into next function
I have a simple issue I can't seem to crack.
It seems like a variable in $rootScope isn't assigned when I call the next function but isn't that the point of a Promise (.then)?
My stack is AngularJS v1.6.4 and NodeJS but this is a pure Angular…

Sean
- 1,151
- 3
- 15
- 37
0
votes
2 answers
Adding and deleting rows from one table to another - AngularJS
Our team is developing in ServiceNow and have a requirement to add rows from "Sending" table to "Receiving" table and delete rows from the "Receiving" table and return it back to the "Sending":
We've nailed down the adding portion of this exercise,…

Dave
- 1,257
- 2
- 27
- 58
0
votes
0 answers
passing data to another controller using $rootScope.$broadcast
its like signup menu first controller gets the data from the user and after the validation
it sends the data to $rootScope and broadcast it so the
second controller can get it and show the data in myInfo tab
don't know whats wrong but the second…

sirH
- 83
- 5
0
votes
1 answer
AngularJS rootScope.$emit from within Directive
I have a directive for users to like (or "fave") posts in my application. Throughout my controllers I use $rootScope.$emit('name-of-function', some-id) to update user data when they like a new post, as this is reflected throughout my application.…

Leon
- 1,851
- 3
- 21
- 44
0
votes
1 answer
Use UI-router to navigate to fromState
AngularJS UI-router has a useful parameter "fromState" which allows me to store where the user came from when they change state. I am trying to implement a system which takes the user back where they left off if they are taken to a subscribe / login…

Leon
- 1,851
- 3
- 21
- 44
0
votes
0 answers
Is the rootScope same or not the same if I open two identical angularjs app?
I developed a single page website with the AngularJS framework.My website will receive logs from other servers and render them on the page. When I open two identical pages of my app in the same browser, I can see that then rootScope (I may use too…