2

I've got a feature that was just reported not working in internet explorer. No idea how long it's been not working, but I imagine it's been since the beginning. I can verify it in IE11.

My app is using angularjs 1.3.17.

There's a button on the form called reset. When they click it, it calls vm.cancel(), which looks like this:

function () {
    vm.working = true;
    vm.disableActions = true;
    manualEntryApi.deleteWageAccounts(vm.selectedEnterprise.RecordID)
    .success(
        function (data, status, headers, config) {
            vm.working = false;
            vm.disableActions = false;
            if (typeof (Storage) !== "undefined") {
                localStorage.setItem("filename", "");
            }
            window.location.href("/FormEntry/#/ManualEntry/?ID="+vm.selectedEnterprise.RecordID);                                             
    })
    .error(
        function (data, status, headers, config) {
            vm.working = false;
            vm.disableActions = false;
            vm.serverErrors = data;
            vm.serverErrorMessage = "Error clearing records.";
            vm.serverErrorMessage2 = "";        
            vm.openErrorModal = true;
    });
});

It POSTs the recordID to an API, which does a bunch of stuff in the back end. It just returns a 200 whenever it succeeds.

After it succeeds, it writes an empty string to localStorage, and then it effectively does a page refresh. You can substitute the window.location.href with window.location.reload() since it's doing the same thing.

However, on the reload, it gives me the $digest cycle error. I thought maybe it was something happening with the ng-init but I commented out the entire block of init code and it still errors. No idea what's going on.

Any idea why that would happen? I tried upgrading to angular 1.4.0, but as this is a legacy app that I inherited, there's a lot of spaghetti and lots of errors thrown by upgrading, so I'm hoping to get it to work in 1.3.17.

I know there are similar posts like this that usually ended up with the OP defining an array inside a for loop and getting this error due to it re-digesting every loop. But the only code I have executing on init right now is this:

    vm.model = {};
    vm.model.PaymentInfo = {};
    vm.selectedEnterprise = $location.search();
    vm.years = [];
    vm.selectedEnterprise.RecordID = $routeParams.ID;
    vm.EitOtherPageTotal = 0.0;
    vm.LstOtherPageTotal = 0.0;
    vm.WageOtherPageTotal = 0.0;
    vm.pageNumber = 1;
    vm.disableActions = false;
    vm.working = false;
    vm.openErrorModal = false;
    vm.serverErrors = [];
    vm.serverErrorMessage = "";
    vm.serverErrorMessage2 = "";
    vm.referenceName = "";
    vm.fileID = null;
    vm.sortOverride = null;
    vm.validFilename = true;
    vm.submitted = false; 

Just some variable initializing.

Alex Kibler
  • 4,674
  • 9
  • 44
  • 74
  • What makes you think the error is related to the code you have posted? – Matthew Green May 19 '16 at 14:39
  • Try to narrow it down. Cut code, test, does it still fail? cut more code. Does it works? You know where to look. – Cyril Gandon May 19 '16 at 14:40
  • Our upgrade from 1.2 to 1.4 was initially thought to be a nightmare, because of all the errors, but we found fixing a couple of them ironed out all the rest in one go, worth perhaps looking into a bit more if you haven't already? – Daniel Dawes May 19 '16 at 14:45
  • @MatthewGreen I actually don't necessarily. I'm completely lost with this one. – Alex Kibler May 19 '16 at 14:46
  • @CyrilGandon, I cut out all of the code that executes other than this, but it's still happening somewhere – Alex Kibler May 19 '16 at 14:46
  • @DanielDawes I'll certainly give it another shot if we can't figure out what's going on. It's just that it's a gigantic app that I'm only familiar with the parts that I've worked on, and there are no regression tests, so I'll have no way of knowing if something broke in the process besides manual testing – Alex Kibler May 19 '16 at 14:47
  • @AlexKibler Sounds familiar ;) - To be fair we always had issues with IE but as it was an internal application we enforced Chrome. Have you got anything in the HTML firing an ng-change that is recursive, or perhaps a `$watch` somewhere. It sounds like it's stuck in a loop somehow – Daniel Dawes May 19 '16 at 15:03
  • I'm not seeing anything in this code that would seem to generate an error. I think you need to provide more or see if you can't narrow it down further. Like @DanielDawes said, you've got something firing in a loop causing the extra digests. – Matthew Green May 19 '16 at 15:13
  • @DanielDawes definitely no `$watch`es, as I try not to use them. However... there are 8 ng-changes. And plenty of them are calling functions, which I could see being recursive. But I don't understand why it's only an issue after I call a function that refreshes the page, and not when it loads initially – Alex Kibler May 19 '16 at 15:16
  • @DanielDawes, I just upgraded to angular 1.4.0. My errors were because I had forgotten to upgrade angular-cookies before but that's taken care of now. However, I'm still getting the digest cycle thing. And it's only in IE, which is strange. However, I just discovered a symptom. In chrome, every time I click reset, it refreshes the page one more time than last time. So if I've clicked it three times, next time I click it, it'll refresh four times in a row. bizarre. – Alex Kibler May 19 '16 at 15:51
  • @AlexKibler How irritating - Does this help? http://stackoverflow.com/questions/13853844/angular-js-ie-error-10-digest-iterations-reached-aborting Maybe use `$location` instead of the window one? `$location.path("/whatever/");` – Daniel Dawes May 19 '16 at 17:07

2 Answers2

1

Try $window.location.reload();

Eric
  • 191
  • 1
  • 10
0

I read a few other answers and similar issues, the accepted way to reload a page in angular is $route.reload();, perhaps this method and using the way Angular expects things to happen will help...

How to reload or re-render the entire page using AngularJS

Angular JS: IE Error: 10 $digest() iterations reached. Aborting

Community
  • 1
  • 1
Daniel Dawes
  • 975
  • 5
  • 16