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
vote
1answer
16 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
44 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
74 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
36 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
30 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
17 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
27 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
86 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
27 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
43 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
23 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
46 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
29 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
44 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
22 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
0answers
29 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
15 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
15 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
81 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
31 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
37 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
39 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
21 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
40 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
26 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
73 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 ...
-1
votes
2answers
49 views

Factory firing before $http request in run

How do I get the authCheck factory to fire before the "Check Login state of user" function? I'm trying to check the state of the $rootScope on routing and http requests: //Global Logout Function ...
0
votes
1answer
79 views

AngularJS ng-src does not update using $watch on $rootScope

I am using the $rootScope to get and update an avatar. Now, when the user updates a new avatar, the ng-src of the should also update, showing the new avatar that has just been uploaded. I have ...
0
votes
0answers
28 views

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 ...
-1
votes
2answers
142 views

AngularJS Best practices to use $rootscope?

I'm a beginner in angular and I try to do this tutorial ( http://sahatyalkabov.com/create-a-tv-show-tracker-using-angularjs-nodejs-and-mongodb/ ) I use the best practices by John Papa. So, i don't ...
0
votes
1answer
45 views

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

If user 'touches' form inputs on profile & forgets to save: show `POP UP` when they click SideMenu icon

I've tried to come up with some sort of "error checker/validation" for my users IF they forget to Save the edits they made on their profiles. The user enters the Profile.html state. They start to ...
0
votes
1answer
63 views

How to set information into index.html outside the ng-view

I'm working with angular for the first time and having some trouble showing some dynamic information in my index.html file. Everything inside the ng-view tag is working great. When a user ...
0
votes
1answer
178 views

Cannot access $rootScope property from controller?

In angular's run block i am setting one property on $rootScope however when controller executes that property doesn't exists on $rootScope. When application starts, in debugger i see "adal:...
0
votes
1answer
50 views

AngularJS on $stateChangeStart loop

In a web application I want that, when the user route in the $state, Angular checks if there is a token and if he has permission. But I have a problem: even if I do event.preventDefault(), it starts a ...
0
votes
1answer
206 views

How to listen to $rootscope.$broadcast with $scope

My $scope.$on(... doesn't seem to be picking up the broadcast. I have an interceptor to capture http response errors and broadcast an event that my main controller can react to. (function () { '...
0
votes
1answer
216 views

AngularJS 1 with TypeScript: where in controller to put $rootScope.on?

Service export class RandomServiceName implements ng.IServiceProvider { /* @ngInject */ constructor(private $rootScope: ng.IRootScopeService) { } public $get(): RandomServiceName { ...
1
vote
1answer
49 views

custom $compile directive applies only sometimes in same scope

thanks for looking. I'll dive right in: A JSON object has HTML links with ng-click attributes, employing ng-bind-html, with $sce's trustAsHtml to make the HTML safe. I have also used a custom angular-...
0
votes
1answer
28 views

AngularJS caching batch entity GET to individual entity services?

So I have an endpoint which returns the contents of many entities in parallel. I have a shared service which calls this endpoint and puts them into a shared $cacheFactory. When GET /base_entity/<...
1
vote
1answer
394 views

use variable in both JQuery in an angularJS

I need to use an array that is being defined in a JQuery script inside of an angularJS controller script. I don't understand how $rootScope fits into this whole thing. Is this possible, Any advice? ...
0
votes
2answers
63 views

Syntax to access rootScope variable in MyController

In the below code, <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script src="https://...
0
votes
2answers
24 views

Variable class not changed when modify $rootscope

I have two controllers: Parent Controller 'use strict'; app.controller('CoreController', function($scope,$window,$location,$rootScope,AuthFactory) { var requiredLogin = true; $rootScope....
0
votes
1answer
37 views

Angular the scop view dont updates may view

I have small app the getting data from signalR and passes them back to controller from the factory. but when the rootScope triggers and pass the object to the scope this data dosent updated on the ...
0
votes
1answer
56 views

Change child scope using broadcast from app.run

I have an angular app with the name DemoProject. I have an app.run controller and one child controller JS var app = angular.module("DemoProject", ['ngRoute', 'ngAnimate', 'ngMessages', 'ngMaterial']...
0
votes
0answers
71 views

Change Values for an angularJS child Controller property in app.run

I having a angular module app in the name of the ng-app DemoProject. Now I'm creating app.run controller and one child controller My AngularJS Script var app = angular.module("DemoProject", ['...
1
vote
3answers
751 views

Best practice for using $rootscope in an Angularjs application?

We have a large Angularjs 1.6 application that has $rootscope scattered throughout the app in over 200 places in filters, services, routes, etc.. so it needs to be refactored, but I'm not sure how to ...
3
votes
1answer
163 views

Image loading issue in custom directive

I want the image URL received from server side in my custom directive. The directive is used to create a canvas. Seems the directive is loaded and the image URL is undefined. As it takes the time to ...
0
votes
2answers
85 views

Why I can't set/get $rootScope?

I try to set a a value in $rootScope in a .run() and try to get it in a service but it looks like it's undefined. Everything else in the .run() and in the service is running fine. .run(function($...
1
vote
3answers
258 views

Unable to update the rootScope in angular

I am trying to send a request to a php file from one controller in angular and getting the response. I stored the response in a rootScope variable which is initialized in the controller.run() method ...