Note that there are some explanatory texts on larger screens.

plurals
  1. PODouble $rootScope in Angularjs app
    text
    copied!<p>This problem makes me a huge headache - I don't know why, but in my application i have two $rootScope, with $id "001" and "003" (each has separated variables). I checked ng-app occurrence and it's only once at main page.</p> <p>Anyone have any idea why it is like that ?</p> <p>Angular 1.1.5 (same on 1.0.7)</p> <p>Index.cshtml</p> <p></p> <pre><code>&lt;html lang="en" ng-app="app"&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;title&gt;&lt;/title&gt; &lt;meta name="viewport" content="width=device-width" /&gt; @Cassette.Views.Bundles.RenderStylesheets() &lt;/head&gt; &lt;body id="body" class="container-fluid" ng-app="app"&gt; &lt;div ng-view ng-cloak class="row-fluid"&gt; &lt;/div&gt; @Cassette.Views.Bundles.RenderScripts() &lt;/body&gt; &lt;/html&gt; </code></pre> <p>App.js:</p> <pre><code>var app = angular.module('app', ['ngResource', 'ngCookies']) .config(['$locationProvider', '$routeProvider', '$httpProvider', function ($locationProvider, $routeProvider, $httpProvider) { var access = RoutingConfig.accessLevels; $locationProvider.html5Mode(false); $routeProvider .when('/', { redirectTo: '/Entries' }) .when('/Login', { templateUrl: 'Views/Security/Login', controller: 'LoginController', access: access.anonymous }) .when('/Entries', { templateUrl: 'Views/Entry/List', controller: 'EntryListController', access: access.user }); }]) .run(['$rootScope', '$location', 'SecurityService', function ($rootScope, $location, SecurityService) { $rootScope.$on("$locationChangeStart", function (event, next, current) { $rootScope.error = null; if (!SecurityService.Authorize(next.access ? next.access : RoutingConfig.accessLevels.public)) { if (SecurityService.IsLoggedIn()) { $location.path('/'); } else { $location.path('/Login'); } } }); }]); </code></pre> <p>Just to make sure both templates are empty. $rootScope is changing on second $locationChangeStart :(</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload