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

$rootscope not holding value

I am using the following code to store username ('pqr') value in rootscope but it is scoped by $http.get mehtod angular.module('myApp').run(function ($rootScope,$http) { $rootScope.username = 'abc'; $http.get('/api/getuser') …
pbd
  • 423
  • 3
  • 8
  • 19
0
votes
0 answers

AngularJS - Refresh all instances of the app on $emit

I've an angularJS app. I've a page with the following template and controller:

{{food}}

codewarrior
  • 984
  • 4
  • 18
  • 34
0
votes
2 answers

Angular js - is printing FALSE value as string

i'm simply trying printing out a param value that is FALSE, and it prints out "false" as plain text, quite unbelievable... any clue ? $rootScope.session = { "username" : $window.localStorage['user_username'] || false, …
itsme
  • 48,972
  • 96
  • 224
  • 345
0
votes
1 answer

Angular js - can't get json into $rootScope

i'm setting up config params, but the console.log() returns me undefined and i can't understand why, i see the json returned from the http call in console!!! app.run(function($rootScope, $location,$http){ var update = function (){ …
itsme
  • 48,972
  • 96
  • 224
  • 345
0
votes
0 answers

angularjs: double change rootscope

I have something like myApp.run(function ($rootScope, $window, $location) { $rootScope.empty_nav = function (showme) { $rootScope.msg_nav_planes=true; $rootScope.msg_nav_tusplanes=true; $rootScope.msg_nav_participantes=true; …
leandro713
  • 1,268
  • 1
  • 10
  • 17
-1
votes
1 answer

Deregister an event in AngularJS

Having a controller, MyCtrl: class MyCtrl { constructor($scope, $rootScope, ...) { this.$scope = $scope; this.$rootScope = $rootScope; this.doThis = _debounce(this.resize.bind(this), 300); ... } $onInit()…
Leo Messi
  • 5,157
  • 14
  • 63
  • 125
-1
votes
1 answer

AngularJS $scope is undefined when a function is called from HTML page not .js file

I have this: $scope.products; I set the value on it like this: $scope.products = plans; where plans is the result I get back from a call. If I debug, here, I have $scope and $scope.products in the debugger. Example: But then I do this from my…
rosu alin
  • 5,674
  • 11
  • 69
  • 150
-1
votes
1 answer

Angular $rootScope object property not accessible

My $rootScope.globals object is below: { currentUser: { id: "56309272279724c02b319392" name: "Özgür Adem" picture: "http://www.gravatar.com/avatar/c4ca4238a0b23452sdcc503a6f76829z? d=retro" ptoken: "mFFa9l25HbB4fbh7" role:…
Furkan Başaran
  • 1,927
  • 2
  • 19
  • 28
-1
votes
2 answers

$scope.$on changes not reflected in the view

I'm doing a broadcast and on listening to the broadcast i'm trying to updated a variable on the scope that I wanted to display on the view, but the changes are not being reflected in the view immediately, until I click on the UI. Anyone know what…
Ajay Srikanth
  • 1,095
  • 4
  • 22
  • 43
-2
votes
1 answer

passing data from controller to service in angularjs

I am new to angular js. I need to access data from my controller to service. I tried using $rooyScope but my service needs to be loaded first and then my controller so using $rooyScope gives me error. so i am unable to get the data stored in…
Rohan Kawade
  • 453
  • 5
  • 18
-3
votes
1 answer

Where is rootScope values are stored? In cookie or local storage?

Where is rootScope values are stored? In cookie or local storage? I have a small doubt about rootScope in angularjs. I have passing a value between two controllers, So I have using the $rootScope. I want to know how to rootScope Working? and…
Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234
1 2 3
11
12