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

learn more… | top users | synonyms

-1
votes
0answers
26 views

Cannot read property 'search' of undefined with $rootScope.location in angular js [duplicate]

I want to get value from query string.value is pass correctly config(['$routeProvider', '$stateProvider', function ($routeProvider, $stateProvider) { $routeProvider.when('/details/:...
0
votes
0answers
16 views

How to have a variable that would updated real time - to all the controllers it applies to

I have a variable which is having a date in the $rootScope which is passed to all the controllers in my site. so a common date value is set, now I want to be able to update this $rootScope variable ...
1
vote
3answers
39 views

AngularJS rootScope undefined in controller

I have a simple AngularJS app that has two template pages: login.html and content.html. I use ng-view and routing to dynamically load those pages into the index.html. That works fine. Here is my ...
0
votes
1answer
17 views

Value undefined in angular custom directive

I tried to make a directive for destroying DOM elements if user doesn't have the permission to see it. I do this as follows: angular .module('digital_equation.auth') .controller('...
-1
votes
1answer
55 views

How to inject $rootScope into AngularJS factory

I'm relatively new to Angular and wasn't able to find an exact answer for how to inject $rootScope into a factory function that's organized like mine. So any help is appreciated. Basically, I'm just ...
0
votes
0answers
34 views

Failed to execute 'replaceState' on 'History' // $rootScope:infdig

I'm using Angular 1.6.1 and UI.Router @version v0.4.2 and getting this weird error which I can't seem to find the solution to. Chrome says Error: Failed to execute 'replaceState' on 'History': A ...
1
vote
1answer
23 views

Is setting the value of rootScope.angular a code smell?

I'm looking at this code that someone else wrote. This looks to me like a bad code smell. What could be a valid reason to copy a reference to angular under the $rootScope? $rootScope._ = $window....
1
vote
1answer
98 views

AngularJS: changing $rootScope variable doesn't change first selected option in ng-model

I have a specific problem which I can't seem to crack. In html I have following code: <select ng-model="$parent.proizvod" ng-options="i.id_proizvod as i.proizvod for i in proizvodiServer"> ...
-1
votes
1answer
27 views

I need to access a variable in .run() module in angular and need to change the value of it in different controllers

.run(['$rootScope', '$state', 'Session', function ($rootScope, $state, Session) { $rootScope.$on('$stateChangeStart', function (e, toState) { console.log('inside .run') if (toState....
0
votes
2answers
104 views

How to call a rootscope fuction in html - Angular Js

i have made a rootscope function in which I am actually logging out the user. But I dont know how to call it in a view . My functions is $rootScope.logout = function () { $cookies....
0
votes
0answers
53 views

How to get an internal ng-model value?

I am working on SPA and I include HTML pages into one basic page by ng-include.Let's call this basic page as external and the included pages as internal.In an internal page I have set an input ...
1
vote
1answer
40 views

Angularjs variable out of ng-view

I want to have particular variable for menu to know which class to be active. Up to now I know how to set variable inside ng-view but I want to keep my menu out of that view. If I set variable in ...
2
votes
2answers
76 views

Route change events while trying to avoid using $rootScope

As the Angular team (and severals blogs) adviced, I try to avoid using $rootScope as possible in my apps. $rootScope exists, but it can be used for evil "Of course, global state sucks and you ...
0
votes
0answers
35 views

How to avoid using $root on component's templates?

I'm trying to check if a user has a specific role from my component's template. For example, this could be my session service : function Session() { 'ngInject'; var userRoles = {}; ...
0
votes
1answer
60 views

Broadcast headers to all resources after calling another one resource

I built a rest api, now it's time to handle data with angular. To do that, I built a service to make a connection to my resources. So I've : angular.module("myServiceRest", ['ngResource']) .factory(...
-2
votes
3answers
85 views

$root scope with same variable with different values

First of all excuse me if this doesn't make any sense. I have a root-scope with two different values assigned in the same controller,and now i want to print those two values using that root-scope........
0
votes
1answer
71 views

Angular / Controller loading a json file fails with an exception I can not understand

sorry, maybe a stupid problem, but I am still a newbie with angular. The code: -- EDIT #2 -- ----- ----- ----- ----- ----- ----- ----- MyApp.controller('DataController', ['$http', function ($...
1
vote
2answers
84 views

angularjs change rootscope after promise in a controller

I'm trying to change some $rootscope variables from within a controller after a I have received a promise from a service. The $rootscope variables are used to set the html page title attribute etc. ...
0
votes
0answers
46 views

Reload the angular view from controller only once

I am trying to go to a view and then reload that view from the controller exactly once. What I have done looks like this. function checkForReport() { if ($rootScope.reportCounter) { ...
0
votes
1answer
15 views

AngularJS' $rootScope. Unable to create internal variable

I'm using $rootScope.requestObj to store an object of key:values that represent certain filters. Throughout all my app $rootScope.requestObj is treated a singleton and it's behaviour is as expected. ...
1
vote
2answers
86 views

$rootScope.$broadcast usage in AngularJS

I am working with an app where I have the following line at the end of a service in service.js. $rootScope.$broadcast('rootScope:Object') Here Object is the output of an API service. If I now want ...
0
votes
2answers
972 views

how to use $route.reload() commonly for all controllers in angular js

In order to retain a $rootScope value on refresh[F5] we can use $route.reload in controller as below: $scope.reloadCtrl = function(){ console.log('reloading...'); $route.reload(); } As i am using ...
0
votes
1answer
55 views

Angular js using $rootScope in ng-src script on refresh fails

I'm creating a project with internationalization, where labels will be in /conf/lang/lang_{{lang}}/labels.js which will included in index.html. lang - rootscope variable setting in app.run(). Index....
1
vote
1answer
2k views

Angular: using $rootScope.$on vs $scope.$on to catch a $rootScope.$broadcast in a component – what is better in terms of performance?

Hi I’m wondering what is better in terms of performance. Let’s say I have this factory that broadcasts stuff: angular.module('core.foo') .factory('Foo', ['$rootScope', function ...
0
votes
1answer
52 views

$state are not workig angularjs

I have 2 pages and I want to pass a variable from page 1 to page 2. page1.html <ion-view ion-title="Home"> <ion-content> <label class="item item-input"> <input type="...
-2
votes
1answer
908 views

Cannot bind to rootscope in Angular 1.5 component

I'm in the process of eliminating the "scope soup" architecture of a legacy Angular 1.5 app following this guide: http://teropa.info/blog/2015/10/18/refactoring-angular-apps-to-components.html#replace-...
0
votes
2answers
74 views

Mapping AngularJs codes to ReactJs?

I'm new to reactjs. I want to know Is there an equivalent for angular services such as $rootScop, $q, $webSocket, ... in reactJs? .service('a', function ($rootScope, $location, $q, $webSocket) { ...
0
votes
1answer
40 views

Reset $rootscope value used to hide back button

I am using ng-hide to hide back button and show it in required pages. In app.js I have following code where i am declaring the initial value to true: var app = angular.module('myApp', ['ui.bootstrap',...
2
votes
1answer
19 views

Fetch server settings after boostrap but before anything else

I've been searching for an answer for this but haven't got any unambiguous or clear answer on how to solve and come about this. In my anguarJS app, I want to make sure that the very first thing after ...
0
votes
1answer
60 views

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 ...
0
votes
2answers
788 views

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(['$...
0
votes
0answers
84 views

Refresh service with $broadcast, $on angular

I'm new with using $broadcast, $on. I have a service that is retrieving an available list of actions that the user could do. On my html page I have a checkbox that can be checked/unchecked. ...
2
votes
2answers
71 views

Rootscope not accessible in function

In the code below I log to console the $rootScope and it logs undefined. Why does it happen? $scope.init = function ($rootScope) { // var s = $cookies.get("arr"); // var ex = []; var ex ...
0
votes
0answers
44 views

$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 ...
0
votes
2answers
51 views

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 ...
0
votes
1answer
57 views

$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(); ...
0
votes
2answers
177 views

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 ...
0
votes
1answer
38 views

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, ...
0
votes
1answer
62 views

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 $...
1
vote
0answers
20 views

Does $routeOnChange placement matter for it to trigger?

Does it matter where we instantiate a $on listener with $routeOnChange? I currently have $rootScope.$on("$routeOnChange", myFunction) in two directives. In one directive the listener works fine when I ...
-1
votes
1answer
18 views

invoke a function after two events have been triggered

$scope.$on("stopSpinner", function() { $('body').mask('hide'); }); the above code works that when stopSPinner is event is recieved, it executes. But my requirement is little more involved....
0
votes
1answer
280 views

$rootScope in AngularJS not working

I am new to AngularJS. I can successfully retrieve JSON data and display it on my html page with $scope (ASP.NET application). However, I am trying to store the data in $rootScope, so that I can ...
0
votes
0answers
21 views

Not able to retrieve common header values in index.html using $rootscope from controllers of different views

I have an application where I want to use a common header for all the pages which consists of startdate and enddate which needs to be displayed dynamically.For each view's controller, I am giving the ...
1
vote
1answer
78 views

Angular $rootScope Behavior on Start and on Refresh

I have the following piece of code in Angular: $rootScope.commands.forEach(function(element, index, array){ commands[element] = function() {alert(element + " Test Command!");} }); It ...
0
votes
1answer
66 views

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 ...
1
vote
0answers
60 views

Access $rootScope value in Kendo Grid for export to excel dynamic file name

This is HTML ------------ <div class="lm-panel panel panel-default"> <div class="lm-panel-...
0
votes
0answers
40 views

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 ...
0
votes
1answer
80 views

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', [])....
0
votes
1answer
55 views

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 {{...
0
votes
2answers
132 views

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