Questions tagged [rootscope]

Every AngularJS 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.

Every part of an AngularJS application has a scope. At the ng-app level, this scope is called the $rootScope. When Angular starts to run and generate the view, it creates a binding from the root ng-app element to the $rootScope. This $rootScope is the eventual parent of all $scope objects. So we can say that the $rootScope object is the closest object we have to the global context in an Angular app.

$rootScope is deprecated. Using it will make migration to Angular 2+ more difficult.

Resources

176 questions
0
votes
1 answer

Angular JS $scope.$on in a directive don't affect scope variable

I made a XHR upload Angular service where I'm trying to broadcast the upload progress via $rootscope ... xhr.upload.onprogress=function (evt){ if (evt.lengthComputable) { percentComplete = Math.round((evt.loaded / evt.total)*100); …
icchio
  • 109
  • 2
  • 13
0
votes
0 answers

AngularJs $rootScope

I have two separate module that both end up at the same view via $rootScope. I'm trying to put a condition in that will allow me to force a user back up a set path. What I need is to be able to add a unique identifier to one of the $rootScopes. What…
Pianoc
  • 763
  • 1
  • 11
  • 32
0
votes
1 answer

PassportJS, AngularJS, $rootScope function is not defined

I’m building an app for 1 admin to be able to log in and edit content. When logged in the app will serve up a private html doc structure instead of those not logged in being presented the normal public docs. I’m using Angular-route, Session and…
DebauchMode
  • 210
  • 2
  • 7
0
votes
1 answer

Do multiple apps create multiple rootscopes?

As shown here, it is possible to add multiple apps to the same page. Also it says in the angularjs documentation that Every application has a single root scope Then does it stand to reason that there are two rootscopes created if I map two apps…
user96551
  • 185
  • 11
0
votes
1 answer

$rootScope variable in ng-repeat Angularjs

I have two different table templates. I keep the visibility of the table using ng-show='template == 1' directive in first table and ng-show='template == 2'inside the second table. I set the template to either 1 or 2 on the controller. I build the…
Vijay VSTO
  • 133
  • 1
  • 4
  • 15
0
votes
2 answers

How to return a new key onchange location in angularjs

The idea is to always have a new key as soon as you change the page, this is my code but I think I have problem $scope.newKey =function (){ var key =0; $rootScope.$on('$locationChangeSuccess', function () { key++ ; }); return…
Youssef Mayoufi
  • 25
  • 1
  • 12
0
votes
1 answer

Get hold of AngularJS Object from inside javascript to open bootstrap modal

The logout() has the code to open model. I only want logout() function to be called if the angularjs object value inside rootscope is true.. How do I check from javascript what is inside the rootscope object? …
0
votes
1 answer

Lifetime of values stored in $rootScope

I wanted to know what is the lifetime of the values stored in $rootScope especially in cases when the page is opened in a different tab.Whether the value gets lost or will it be retained in the newly opened tab?
forgottofly
  • 2,729
  • 11
  • 51
  • 93
0
votes
2 answers

How to communicate controller with each other in AngularJS?

I'm writing a controller. This controller has to communicate with an other controller. But I don't know is it posible? HTML:
0
votes
1 answer

AngularJS not updating view after $broadcast

I know I'm not the first who has this problem but no solution over here helped me to solve it. I've two controllers a ShowController and a CreateController. I want to broadcast from the ShowController and receive in the CreateCrontroller. To do so…
0
votes
1 answer

How to change the AngularJS scope in a different HTML page?

I hope someone can help me with this problem, it really drives me crazy :P I have created a Plunker in order to illustrate the problem. See the Demo here http://plnkr.co/edit/BRlDgKYlE87Bh3t53tpZ?p=preview. My code is in the plunker. So my problem…
Thomas M. Tveten
  • 467
  • 1
  • 9
  • 22
0
votes
2 answers

rootScope is upating on scope variable update

I have created a rootScope variable like $rootScope.globalData = data; $rootScope.globalData.chillerConditions.HeatSource.Value = "ST"; //Default Value $scope.chillerConditions.HeatSource.Value = 1; //Default Value where…
Romesh
  • 2,291
  • 3
  • 24
  • 47
0
votes
2 answers

Jasmine spyOn $rootScope

The problem: - using AngularJs - given an implemented a service - trying to test it with Jasmine Here is how my service looks like: angular.module('app.common').service('StateInterceptor',['$state','$rootScope',function($state,$rootScope){ …
Iamisti
  • 1,680
  • 15
  • 30
0
votes
1 answer

watching angularjs $rootScope variables

I am initializing a function in my app run function with $rootScope like this - angular.module('student').run(function($sce,$rootScope, $location,mvNotifier,$http) { $rootScope.getUser = function(){ var url = '/getUser'; …
0
votes
0 answers

How to avoid data mix between $scope variables in ng-repeat when it is broadcasted in other controller?

I have two controllers. In one controller I am storing the data in scope variable for different categories and for different weeks and days. Here is the function for the same: $scope.fetchWeekList = function(type) { $scope.loading = true; …