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
0
votes
0 answers

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 = response.data.userRole; $rootScope.userRoleId =…
Vishal B
  • 653
  • 2
  • 12
  • 31
0
votes
1 answer

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, $location, $window, $http, $rootScope) { …
Raj
  • 65
  • 1
  • 2
  • 10
0
votes
2 answers

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', 'InitialiseService','$window', function($rootScope,…
tekin
  • 145
  • 4
  • 15
0
votes
3 answers

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 are the reasons, whether they are AngularJS best…
0
votes
1 answer

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('AuthLoginController', AuthLoginController) …
0
votes
1 answer

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 trying to inject $rootScope because I'd like to…
Pete
  • 113
  • 11
0
votes
0 answers

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 attribute to be ng-model="userd.Username" and in the…
user6561572
  • 219
  • 3
  • 14
0
votes
1 answer

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("myService", function ($rootScope, $resource)…
kabrice
  • 1,475
  • 6
  • 27
  • 51
0
votes
1 answer

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 ($http) { var self = this; var objects…
0
votes
1 answer

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. However, when making a call to an external API, I…
0
votes
2 answers

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 so many controllers, is there any way to use…
Indhu
  • 371
  • 1
  • 5
  • 18
0
votes
1 answer

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.html
Indhu
  • 371
  • 1
  • 5
  • 18
0
votes
1 answer

$state are not workig angularjs

I have 2 pages and I want to pass a variable from page 1 to page 2. page1.html
0
votes
2 answers

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? code: .service('a', function ($rootScope, $location, $q, $webSocket) { this.init = function () { b() …
ParisaN
  • 1,816
  • 2
  • 23
  • 55
0
votes
1 answer

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', 'ui.router', 'ui.mask', 'ngSanitize',…
Veer
  • 166
  • 1
  • 1
  • 16