Angular controller only loads the first time in IE
I'm trying to set up a controller that redirects the user to a specific home page when navigating to a specific url. This different users can have their own landing page.
I have a fortune
.state('database.home', {
url: '/home',
templateUrl: "app/Database/Home/home.html",
controller: "DatabaseHomeController"
})
and controller
(function (ng, app) {
"use strict";
app.controller(
"DatabaseHomeController",
["$rootScope", "$scope", "$state", "$stateParams", "sessionService", function ($rootScope, $scope, $state, $stateParams, sessionService) {
console.log("Database home controller running");
$stateParams.systemName = sessionService.auth.DefaultSystem;
$stateParams.objectName = sessionService.auth.Homepage;
if ($stateParams.objectName) {
$state.transitionTo("database.object", $stateParams);
} else {
$state.transitionTo("login");
}
}]);
})
(angular, WebAppName);
This works once in Internet Explorer, but on demand in Chrome / Firefox.
This logging line only appears the first time you click the home link or type url in IE. Every time I see
0x800a139e - JavaScript runtime error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
in angular.js
Edit:
Too clear as two people asked. $ StateParams is not the cause of the problem.
if (sessionService.auth.Homepage !== "") {
$state.transitionTo("database.object", { objectName: sessionService.auth.Homepage, systemName: sessionService.auth.DefaultSystem });
} else {
$state.transitionTo("login");
}
Behaves exactly the same as it only works once in IE, but every time in Firefox and Chrome.
Edit 2:
Changing $ state.transistionTo for $ state.go doesn't matter, the infinate loop remains in IE on subsequent uses.
+3
source to share