Questions tagged [angularjs-rootscope]

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.

152 questions
3
votes
4 answers

I am unable to access $rootScope in my controller

I have some parameters in the $rootScope as specified below: myApp.factory('itemService', function($http) { return $http.get('/items'); }); myApp.run(function($rootScope, itemService) { itemService.success(function(response) { …
The Oracle
  • 2,373
  • 3
  • 26
  • 44
3
votes
2 answers

AngularJS - Accessing ng-init variables from run method

1) I have variables initialized in ng-init Eg - ng-init="password='Mightybear'"; 2) I want to access it from the .run method. Eg - anguar.module("ngApp", []) .run(function() { //Access password here }); Below scenarios I have tried, and did…
2
votes
2 answers

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 should use $rootScope sparingly, like you would…
Mistalis
  • 17,793
  • 13
  • 73
  • 97
2
votes
1 answer

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 AngularJS has been loaded / bootstrapped, it goes…
2
votes
2 answers

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 = $cookies.get("arr"); $scope.arry =…
jayendra bhatt
  • 1,337
  • 2
  • 19
  • 41
2
votes
1 answer

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? $(document).ready(function(){ …
2
votes
3 answers

AngularJS Code Understanding

Can someone please help me explain this code segment in AngularJS $rootScope.compiledScope = $scope.$new(!0, $rootScope), $scope.variable = "someValue"; What is $new operator serving here What is !0? How , is used to separate two statements and…
khawarizmi
  • 593
  • 5
  • 19
2
votes
0 answers

Error while testing promise with Jasmine unit test

I've been writing some unit tests in Jasmine and I have a function that returns a promise in a service which I use in my own factory. I'm doing the following steps: inject(function(_$rootScope_, _$q_, swIncludedService){ includeDeferred =…
2
votes
1 answer

Angular Broadcast not working

I am unable to broadcast to other controllers as I have no parent child relation ship therefore, using $rootScope to broadcast the change to other controllers. Please help me to identify the problem in code. function serverController( server,…
Sam
  • 376
  • 3
  • 10
1
vote
0 answers

$rootScope.on is calling twice before destroy in angularjs

In this issue, first time it is coming into else block where downloadCsv method is getting called then rather destroy the component is again comes into if block. Somehow subscription has made twice in this method. How can we reduce that? Is there…
1
vote
1 answer

Accessing rootScope variable in template view not working

I know this is possible and have seen many threads on how to do this but I can't figure out what I am doing wrong. My $rootScope variable is not appearing in my template view. .run(function($ionicPlatform,$state,$rootScope,$q,apiService) { …
rolinger
  • 2,787
  • 1
  • 31
  • 53
1
vote
0 answers

AngularJS multi screen validation on last step

I have an angularJS application. I have implemented a generic workflow using $routeProvider, templateUrl & Controllers. Each step(screen) is verified when user click on next button and moves to the next step if validation passes. If validation…
1
vote
2 answers

Methods of saving user info in AngularJS

I want to know about the ways of saving user info. Many seniors have recommended using $cookieStore, or Authentication or etc. But how about using $rootScope? My idea is when user has logged in, saving his/her id and password into…
1
vote
0 answers

find the cause of Error: [$rootScope:inprog] $apply already in progress

My application has a dashboard with some panels, each one with a chart.(I use Angular-Chart.js) Each panel is a different custom directive. I have TickService with a global tick, broadcasted each 1sec function sendUpdateTich() { …
DeLac
  • 1,068
  • 13
  • 43
1
vote
2 answers

Multiple parent-child scope event trigger issue

I have a directive for parent scope, I also have another directive for child scope. In a template, I have several parent-child scope. Like this. ParentScope1 - ChildScope1 ParentScope2 - ChildScope2 If I change a value in Parent, I will broadcast…
user8565199
  • 133
  • 2
  • 8
1
2
3
10 11