I'm trying to setup a controller that will redirect a user to a defined home page when they navigate to a specific url. This is so different users can all have their own landing page.
I have a state
.state('database.home', {
url: '/home',
templateUrl: "app/Database/Home/home.html",
controller: "DatabaseHomeController"
})
and a 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.
That line of logging is only shown the first time I click on the home link or type the url into IE. Every subsequent time I see
0x800a139e - JavaScript runtime error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
in angular.js
Edit:
Too clear up as two people now have asked. The $stateParams isn't 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 in that it only works once on IE but every time in Firefox and Chrome.
Edit 2:
Changing $state.transistionTo for $state.go makes no difference the infinate loop on subsequent usages remains in IE.