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 ...
0
votes
0answers
5 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
2answers
37 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
24 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
42 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.
...
1
vote
3answers
44 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 ...
3
votes
3answers
53 views
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
votes
3answers
41 views
How to pass an array from one view to another within same controller
I am just a newbie to angularjs. I have a form in one view of my application which shows on my other view. There is only one controller for the application. The user can enter the fields in the form ...
2
votes
0answers
23 views
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_, ...
0
votes
1answer
24 views
delay in hiding loader icon after $stateChangeSuccess
I know there's a lot written about this, but I can't find a solution to this particular problem. When changing a state, I want the current state to be hidden and for the spinner to be displayed on ...
1
vote
0answers
44 views
Convert this $rootScope to factory used in http basic authentication angularjs
I am using this example to build a HTTP Basic authentication app with angularjs.
http://jasonwatmore.com/post/2014/05/26/AngularJS-Basic-HTTP-Authentication-Example.aspx
The writer uses $rootScope to ...
2
votes
3answers
54 views
Why use $rootScope to share data across controllers when factories can do the same thing?
My understanding is that $rootScope is some kind of global variable which allows it to be shared across controllers. Factories can also do the same thing. So, why not use a factory instead? When ...
0
votes
2answers
60 views
Angular $rootscope.$broadcast correct usage in a service
From what I've read, it seems using $rootScope.$broadcast is not advisable unless absolutely necessary. I'm using it in a service to notify a controller that a variable has changed. Is this incorrect? ...
0
votes
1answer
25 views
how to change the part of url if condition will match in ui-router?
I have two kinds of states in my $stateProvider which are authenticated user access url and public access url..
I have some sort of urls in public access , the thing is i need to prevent these url to ...
0
votes
1answer
44 views
AngularJS $rootScope does not like dashes in string
I want to store a date string in $rootScope but as soon as I do it throws infinite digestion errors.
$rootScope.lastWeek = '2015-12-03';
$rootScope.yesterday = '2015-12-09';
Why can't I do ...
4
votes
6answers
81 views
Show and hide using $rootscope
I have a search bar in my index.html template that I need to hide on some pages. I am using ui-router and $state.
The only way I can make this work is to inject $rootscope into all my controllers to ...
0
votes
2answers
70 views
Angular pass input value to $rootScope variable
I have situation where I want to use $rootScope variable and update its value with the one entered in input field. I have sitauation code shortened to this DEMO:
HTML:
<div ...
0
votes
2answers
103 views
$rootScope is undefined in controller
I am getting very strange issue in angular. I have defined $rootScope.user_info in run method. But when i am fetching the root scope in controller, sometimes i am getting undefined method ...
0
votes
2answers
136 views
AngularJS - $rootScope variable initialization fails
I'm trying to initialize a $rootScope array variable (arrayX) and use it in a $rootScope function in the same controller (controllerA).
The reason i'm using $rootScope instead of $scope for this ...
2
votes
1answer
78 views
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 ...
0
votes
0answers
50 views
angular rootscope infdig error with auth interceptor
I have an angular fullstack app generated from angular-fullstack yeoman generator and I have the following error in my browser console -
Uncaught SyntaxError: Unexpected token e angular.js:1072
...
0
votes
1answer
40 views
rootscope getting reset when i change url directly from browser
I am using ui-router and states. When user logs in in rootscope i add a variable called profile and push in the logged in details. When i change state from UI i.e. clicking on a link rootscope.profile ...
0
votes
3answers
31 views
Querying a JSON-Structure in Angular: Find the right index and get a certain property of it
Assume, following JSON Structure is existing:
[
{
"role_id": 1,
"role_name": "Admin"
},
{
"role_id": 2,
"role_name": "Editor"
}
]
and stored in $rootScope.roles.
What I ...
0
votes
0answers
121 views
Can't access scope data in Angularjs
I am currently working on angular app and bumped into a problem. The problem is when I'm getting the data form backend through factory into controller, eventhrough I apply this data to scope I can't ...
0
votes
1answer
37 views
dynamic multidimensional arrays looping
I need to create a multidimensional array using intervals. I have 5 users who's data grows every 5 seconds. Each user needs array to hold this data that can be accessed for each user later.
...
5
votes
1answer
64 views
Difference between $rootScope and $rootScope.$root
Is there any difference between $rootScope and $rootScope.$root?
What is the difference between
$rootScope.global.flag = true and $rootScope.$root.global.flag = true
Do both of them access the ...
0
votes
0answers
108 views
Communicate to a sibling controller who is not explicitly defined
Hello I have the following situation
I have a controller with a Method, that sets a timeout and calls a modal along with other actions:
angular
.module('app')
.controller('GlobalController', ...
0
votes
0answers
24 views
Reinit the values of many controller into another in AngularJs
So, I have a problem with my application in AngularJS. And I haven't found proper solution yet.
Issue:
I have several templates and each of them recovers part of a user reporting.I have several ...
1
vote
1answer
66 views
$rootScope event preventDefault doesn't stop succeeding handler
I'm using ui-router and registered two $stateChangeStart handlers for login page redirection.
function func1(e,to,toParams, from, fromParams){
....
if (notAuthenticated) {
...
1
vote
0answers
560 views
Error: [filter:notarray] Expected array but received an object
Hi I am trying to create a basic global search which will filter results on the pages depending on which view (controller) is present.
Search controller:
<form ng-controller="searchCtrl">
...
0
votes
1answer
67 views
How to Cancel $interval Method withOut ng-click?
Actually I Need to Fire $http call to get the data for every 5 Seconds From One Controller.
I need to Cancel the Interval in the Other Controller .
Code Follows :-
Controller 1(Find all Events):-
...
0
votes
0answers
60 views
$modal.open() actions in result not updating in form validation directive
I have an angular directive called "show-errors" that I use for form validation. This will apply the "has-error" css class to the containing div when validation fails. This works great in most ...
1
vote
2answers
265 views
Angular: Reload $rootscope user before initializing controller
I'm working on a SPA with AngularJS. After the sign in, a cookie is created with a token and a user object is stored in $rootScope.user which is conveniently accessible from various controllers as ...
6
votes
4answers
168 views
AngularJS: $rootScope:infdig error when calling a ng-style function inside ng-repeat
I'm trying to build an animation on some phrases that will be displayed on the site main page, in a random position and with fade and translate effects.
I would achieve this using ng-style attribute ...
0
votes
0answers
126 views
AngularJS - Dynamically Change Template URL based on rootScope's value in routeconfig
define([], function () {
var routeResolver = function () {
this.$get = function () {
return this;
};
this.routeConfig = function () {
var ...
0
votes
1answer
62 views
can't get rootscope working in controller
so im trying to broadcast a event from a controller to another.
but i keep getting this error
my controller look like this.
angular.module('myApp',[]).
controller('20SettingsController',
...
3
votes
1answer
156 views
access $scope from $rootscope angularjs
I would like to know if there is a way to access the $scopes variables using the $rootScope such that if a function is defined in scope I can invoke it using $rootscope to or if there is a variable ...
0
votes
1answer
37 views
$scope value not able to read in controller
I am not sure what is wrong with this but somehow not able to read correct value of $scope.
Here is my code at controller -->
$scope.verifyMobile = SearchFactory.verify.query({uuid: uuid});
The ...
1
vote
1answer
63 views
Adding templateUrl dynamically while setting $routeProvider $ angular.config
I am angular newbie.I would like to achieve following code...
$routeProvider.when('/view', {templateUrl: ...
0
votes
0answers
48 views
Message pub/sub in angularjs
I am creating a messaging service in angularjs project I am working.
(function (angular) {
'use strict';
angular.module('MyApp').factory('messagebus', messagebus);
messagebus.$inject = ...
3
votes
4answers
172 views
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) {
...
0
votes
1answer
126 views
Use of $rootScope value module.config throwing error
this is my app.config
app.config(['$translateProvider',function ($translateProvider) {
$translateProvider.useUrlLoader('/api/sitecore/translations/get?pageName=' + $rootScope.currentPage + ...
0
votes
2answers
423 views
$rootScope property value undefined in service
I have a table in a database that i need to access before anything else goes on in my website. The values that i get, i'll be using all throughout different controllers, directives, services etc. I ...
0
votes
3answers
524 views
angular-meteor $rootScope.currentUser is undefined
I have a fairly simple application I am building using angular-meteor. Below is my app.js file. When a user logs in, they are redirected to the home state. Usually, $rootScope.currentUser exists, and ...
0
votes
2answers
39 views
AngularJS : How to update directive scope from child controllers
I have a simple parent/child controller set up as follows:
<body ng-controller="ParentCtrl">
<section my-directive></section>
<div ng-controller="Child1Ctrl">
...
1
vote
2answers
487 views
Run a function every time an Angular controller is loaded
I want to run a function every time any Angular controller is loaded.
The best way I have found is to attach this handler in the first controller loaded on my site:
...
0
votes
2answers
181 views
$rootScope.$broadcast on $rootScope.$on: RangeError: Maximum call stack size exceeded
I want to define page title in angular like this :
a standard PageController :
angular.module('admin').controller('AdminController',
function($scope) {
// emit an event to rootscope
...
1
vote
1answer
76 views
Custom expiration date directive throwing rootScope digest error
I have 2 input fields that need to get validated after both fields have been entered. It's a credit card expiration date, so theres a month and year. I'm using a third-party service to actually do the ...
0
votes
0answers
124 views
ionic app.run deviceready rootscoop variable not working
In my ionic app I have the app.run function and a device ready function inside it:
app.run(function($rootScope, $ionicPlatform, $cordovaPush) {
document.addEventListener("deviceready", ...
0
votes
0answers
637 views
Error: [$rootScope:inprog] $apply already in progress
I just tried to use 'ngTagsInput' in my angular app and the tags in the app are running fine,but sumultaneously its throwing the error in the console.Its not affecting my UI flow but yes errors are ...
1
vote
1answer
74 views
Is there something similar to angular $rootScope in Polymer.dart?
I know that in angular exists something called $rootScope. This one contains variables that are going to be shared by all the controllers. I'm looking for something similar for Polymer, so that I ...