I've got an angular application that uses a manually bootstrap so we can load in dependencies before the application starts. This application uses UI-router as well.
Seems as though that when we bootstrap the application on Internet Explorer with our code minified an infinite digest loop occurs when the application bootstraps. The infinite digest loop occurs somewhere in UI-Router and I've narrowed it down to one of the following code snippets (I think).
$urlRouterProvider.otherwise(function ($injector, $location) {
var $state = $injector.get("$state");
$state.go("defaultState");
});
And in another section:
$rootScope.$on('$locationChangeSuccess', function (e) {
e.preventDefault();
if (hiSessionStorage.get('retry')) {
$location.url("/" + hiSessionStorage.get('retry'));
hiSessionStorage.remove('retry');
}
$urlRouter.sync();
});
The above code, the $locationChangeSuccess
function keeps getting hit, and I'm sure it's connected to the infinite digest.
I know this is a fairly common problem and some people have been able to solve it various ways. I've tried the most common outlined here:
https://github.com/angular-ui/ui-router/issues/600
But the above code uses this technique and it doesn't work.
I've also tried the technique here:
To use an actual "otherwise" state instead of a redirect, but no luck.
In addition, I tried to put the e.preventDefault();
and $urlRouter.sync();
inside the if statement in the $locationChangeSuccess
listener, but that screwed up quite a few other things, so I wasn't able to do that.
I have a solution (workaround) to this problem, which I would like to post as an answer (if no one else has answered this before I'm able) because I spent two days solid on this problem before finding a workaround and would prefer others do not share the same pain I experienced.