151 questions
1
vote
0
answers
63
views
$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 ...
1
vote
1
answer
389
views
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($...
-1
votes
3
answers
306
views
Async variable stored in $rootScope not available in other controllers
I am using Angular 1.x for my stack and when I make an API call and store the response in the $rootScope, it is not accessible in other controllers' view.
My controller:
angularApp.controller('...
0
votes
1
answer
64
views
Angular JS 1.x - Can't pass $rootScope variable into next function
I have a simple issue I can't seem to crack.
It seems like a variable in $rootScope isn't assigned when I call the next function but isn't that the point of a Promise (.then)?
My stack is AngularJS ...
0
votes
2
answers
116
views
Adding and deleting rows from one table to another - AngularJS
Our team is developing in ServiceNow and have a requirement to add rows from "Sending" table to "Receiving" table and delete rows from the "Receiving" table and return it back to the "Sending":
We've ...
0
votes
0
answers
148
views
passing data to another controller using $rootScope.$broadcast
its like signup menu first controller gets the data from the user and after the validation
it sends the data to $rootScope and broadcast it so the
second controller can get it and show the data in ...
3
votes
2
answers
2k
views
AngularJS $rootScope.$on alternative in context of migration to Angular2
Our AngularJS project had start it's long way to the modern Angular.
The ngMigration util recommend me to remove all the $rootScope dependecies because Angular doesn't contain a similar concept like $...
0
votes
1
answer
132
views
AngularJS rootScope.$emit from within Directive
I have a directive for users to like (or "fave") posts in my application. Throughout my controllers I use $rootScope.$emit('name-of-function', some-id) to update user data when they like a new post, ...
0
votes
1
answer
189
views
Use UI-router to navigate to fromState
AngularJS UI-router has a useful parameter "fromState" which allows me to store where the user came from when they change state. I am trying to implement a system which takes the user back where they ...
0
votes
0
answers
29
views
Is the rootScope same or not the same if I open two identical angularjs app?
I developed a single page website with the AngularJS framework.My website will receive logs from other servers and render them on the page. When I open two identical pages of my app in the same ...
0
votes
2
answers
56
views
Value from $rootScope is not loaded properly
So I'm basically trying to get a property from my $rootScope when the page loads. I need this property so I can display the value in my form.
After testing this:
console.log("DEBUG $rootScope", $...
0
votes
1
answer
1k
views
ServiceNow: issue with recordWatch and $rootscope timing
Our team is developing an application in ServiceNow. We have a recordWatch on a widget that updates dynamically, but we also want to use rootscope to broadcast data to another widget and have ...
0
votes
1
answer
83
views
Propagating Scope Events from a Factory
Neither $rootScope.$broadcast nor $rootScope.$emit is working from my factory
I have $rootScope injected into the factory. The factory returns this function:
alertHook: function() {
$rootScope.$...
0
votes
2
answers
644
views
How to call an Angular method when browser closes
I'm relatively new in AngularJS and I have been asked to modify our application so that when the user closes the browser, we also log them out of Auth0 service.
I have the code below but I can't get ...
0
votes
0
answers
39
views
AngularJs : How to know if an URL's change is from adress bar or from component action
I'm creating an AngularJs web app and I need to know if an user enter an url in the address bar. In this case I will destroy the current context to initiate a new one.
I tried to use the $rootScope.$...
0
votes
0
answers
84
views
scope.apply is not working in Angular Event Handler
I have a parent page _jobs.html which has a ng-include
<div id="jobs-details" ng-controller="JobsController as jobsCtrl">
<container container-id="jobs-details-container-portlet" ...
0
votes
1
answer
36
views
ui.router nested States, nested Views: $rootScope.$on $rootScope.$broadcast doesnt connect
i use $rootScope to send data to a controller from a nested state and view
It works between 'items' and rootSelector,
It does not work between 'detail' and rootSelector
something blocks my ...
1
vote
0
answers
171
views
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 ...
0
votes
1
answer
424
views
Why I can't just access the root-scope variable in the HTML's <script> </script> part?
I am a newbie to AngularJs and I am building a simple AngularJs web, I have set up the page and it works as I expect. But when I try to use the rootscope variable in the script part of my index.html. ...
0
votes
1
answer
97
views
Define rootscope variable in an .ASPX file
I am trying to define an AngularJS rootscope variable in a .ASPX file to use in a TypeScript file, but I am unsure of how to do this. I am open to any way to be able to define a value in an .ASPX file ...
0
votes
1
answer
1k
views
Why is rootScope.on called multiple times in my application?
In my AngularJS application, I have a controller-A and a factory. I am using the following code in factory to call the function in controller-A. In the initial call, the function in controller A's ...
0
votes
0
answers
838
views
Using $rootScope to call a function on callback
Our team is building a Service Portal page in ServiceNow and have a widget that opens a Material modal window via ng-click:
<md-button id="small-btn" class=" btn1" ng-click="showAdvanced($event)" &...
0
votes
2
answers
1k
views
Angularjs - How to prevent user from going to inner pages without logging in and how to store session upon successfull login
I am using angularjs and angularjs ui-route. I am building a login page and I want to prevent any user to go to inner pages without logging in. I have found a similar question but it lacks ...
0
votes
2
answers
234
views
Can I have $scope value in $rootScope?
I have scope value which I need in rootScope so I can use it across app, and so I did it like
var app = angular.module('myApp', []);
app.run(function($rootScope) {
$rootScope.car= 'honda';
})...
0
votes
2
answers
36
views
Setting nested properties in Javascript / AngularJS
I'm using AngularJS, and I want to set some config vars in my controller.
For example:
$rootScope.config.showPosts.users = true;
$rootScope.config.showPosts.businesses = false;
$rootScope....
1
vote
2
answers
84
views
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, ...
0
votes
1
answer
53
views
AngularJS: Applying a function to 2-way data binding with a reroll button (reloadRoute??)
AngularJS APP
I would like to understand how I can solve this issue of the infinite digest Loop, should I write a conditional?
The objective is to use angular's 2-way data binding, but I need to ...
2
votes
0
answers
1k
views
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 ...
1
vote
2
answers
109
views
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
- ...
0
votes
0
answers
191
views
Find rootscope parameters at controller on load
I have defined rootscope parameters in .run method as follows. `
app.run(function($rootScope,$http) {
$http.get('user/getBaseinfo').then(function success(response) {
$rootScope.userRole = ...
0
votes
1
answer
1k
views
How to pass value from one js file to another js file using rootscope in angular js?
I have js file lets say: login.js where I have defined root scope variable and assigned some value, something like this:
mainApp.controller('loginController',function($sessionStorage, $scope, $...
-1
votes
1
answer
406
views
How to inject dependencies into resolveRedirectTo of routeProvider in angularjs
Please help me understand with an example how to inject $rootScope into $routeProvider's resolveRedirectTo. I checked the official documentation (https://docs.angularjs.org/api/ngRoute/provider/$...
1
vote
3
answers
1k
views
Disable button in one controller from another
Consider I have two controllers Ctrl1 and Ctrl2. On clicking a button in Ctrl1, the button in Ctrl2 should be disabled.
Any sample code for this??
0
votes
2
answers
322
views
How to make a generic close button for angular ui-views?
I need a function where I can use $window.history.back() to be called from every view regardless of what controller is controlling that page.
.run(['$rootScope', '$state', 'CommonUserModel', '...
0
votes
3
answers
524
views
Why should I use $rootScope if I can use $scope.$root?
Since $scope.$root is a reference to $rootScope and therefore the same thing, why should I bother injecting $rootScope when I need to use it if I already have access to it through $scope.$root? What ...
5
votes
1
answer
24k
views
TypeError: "this..." is not a function [duplicate]
I define hostService as follows. The senario is I call first hostService.addListener() in the controller, then the controller may emit a message by $rootSceop.$emit, hostService is supposed to handle ...
1
vote
3
answers
2k
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
1
answer
676
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('...
0
votes
1
answer
1k
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 ...
1
vote
1
answer
64
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....
2
votes
1
answer
3k
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
vote
1
answer
308
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....
4
votes
2
answers
5k
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
0
answers
169
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
1
answer
769
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
2
answers
977
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 ...
1
vote
0
answers
415
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
1
answer
169
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(...
-1
votes
2
answers
713
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
1
answer
215
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 ($...