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
0
votes
1 answer
Angular $rootscope.$on where to activate deregistration function
I have event listeners activated by:
var unregisterSubscription = $rootScope.$on(event, handler);
The event is activated in component and/or directive.
I want the listener to listen when the user uses the scope of the listener, otherwise not.
now…

Zakk
- 758
- 3
- 11
- 20
0
votes
2 answers
Angularjs: Uncaught ReferenceError $rootScope is not defined
I am trying to run and got this message:
Uncaught ReferenceError: $rootScope is not defined at app.js line 12
here is my js/app.js
angular.module('addEvent', ['ngRoute'])
.config(['$routeProvider', '$locationProvider',…

Nil Sagor
- 333
- 1
- 8
- 19
0
votes
0 answers
$rootScope seemingly updating too slowly in an asynchronous call
I'm attempting to achieve a sliding left/sliding right effect (like navigating a flow in an app) with ui-router and ngAnimate.
To achieve this effect, I am adding a css class on the container of the ui-view elements as follows:

Kevbot
- 474
- 8
- 21
0
votes
2 answers
Angularjs - How can editable data be shared between run, factory and controller blocks?
tl;dr - app.run resets $rootScope.variable's value every time I invoke an API - I need help finding a way around that.
I have an AngularJS + ASP.NET Web API setup. I need AngularJS to send a token in every API call except login API, I have placed…

Ekta
- 27
- 10
0
votes
1 answer
$rootScope.$broadcast from controller and $scope.$on in directive is not working 1.2x version
I'm trying to call $rootScope.broadcast from my controller and want to listen it in the directive
Controller:
function startfunction(){
$rootScope.$broadcast('sharingFn');
}
startfunction();
Directive:
$scope.$on('sharingFn',function(){
…

rUI7999
- 129
- 1
- 3
- 20
0
votes
2 answers
Ng-Repeat not updating until page is refreshed
To give a brief rundown of what I am working on:
This app is a phonebook that makes a call to our backend system and returns a JSON payload which is then parsed and stored to Local Storage for offline access and then the data is reflected in a…

Michael Amato
- 55
- 9
0
votes
1 answer
Angular update list $rootScope:infdig
i'm trying to update a scope list inside a callback function. This apparently works fine, but, after some seconds, console gets error: [$rootScope:infdig]. I tried to disable two-way databinding, but, the error…

Henrique Belfort
- 21
- 1
- 5
0
votes
1 answer
Passing AngularJS scope to a JS Chart
I am trying to use an Array from a controller which is within a $scope globally declared in that controller within some Javascript in my html file. Is this possible to do? I have tried to implement $rootScope without much success not sure if there…

Akber Ali
- 13
- 6
0
votes
1 answer
Angular - UI Router - control access to state and redirect
I develop a website with authentication process. User can be admin or not.
I write different components and differents states to route users.
I already control HTTP requests to handle anthentication process, but I want to force redirection when…

Bellito
- 1
- 1
0
votes
0 answers
previous button functionality on multistep form angular
I am using Angular and implementing multistep form using THIS Approach.
I am saving one step's data in localstorage on click event of next button and save at the last step but when previous button is clicked pervious form is empty.i want to retain…

N.A
- 855
- 4
- 13
- 34
0
votes
1 answer
How to store $rootscope variable's value inside $scope?
Is it possible to use rootscope's vriable inside scope?
If yes then how?
For example, I want to set value of $rootScope.user_name in sub_menu property of scope.
var app = angular.module('myApp', []).run(function ($rootScope) {$rootScope.user_name =…

Abhijit Saxena
- 28
- 8
0
votes
1 answer
A way to load service to all of the components in angular 2
I built a service that called lang.service.ts. What it does is simply a key: value mechanism. Whenever I need it to my component, I import it and declare it in the constructor and then I use it as {{lang('key').text}}. so far, so good.
The thing is…

Eliya Cohen
- 10,716
- 13
- 59
- 116
0
votes
2 answers
Best way to keep data is Factory variables or RootScope variables in angular across controllers
I have an angular application with 5000 array values in different variables. I need the same values across 3 controllers among the 5 controllers in whole project. Now I am using factory to keep the data across these. Is $rootScope a better efficient…

Velu S Gautam
- 822
- 9
- 18
0
votes
0 answers
watch and apply changes to object in angular js service
i am trying to change and apply the value of an object in an angular js service.
i have been able to successfully watch the object and i saw the changes but i cannot apply it to take effect .
i am changing the value from my login controller .
i am…

iTech
- 97
- 2
- 11
0
votes
1 answer
Which is the best way to store several external json file in $rootScope in Angular 1.5?
I have 3 json files to build the front-end of my web app:
config.json to get all options based on the user rights
preferences.json which is the user preferences
foo.json which is the object that the user will modify thanks the web app
In my main…

J.BizMai
- 2,621
- 3
- 25
- 49