Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

AngularJS - 1.1.2 - ngView/location/route problem with IE 9 (I think "10 $digest() iterations reached" is just the first part of the problem)... #2007

@swbannerman

Description

@swbannerman

I adjusted this example slightly to demonstrate the problem(s)...I think there may be two:

http://docs.angularjs.org/api/ng.directive:ngView

I've stored the files to replicate the problem(s) here:

http://plnkr.co/edit/Gc6ES0boirDdfHAZAATl

They do not appear to work directly from the plunker preview (as the templates don't seem to get loaded properly); however, if you zip/download/install them and then run the web-server.js, you should be able to replicate them.

With "web-server.js" running, try to load "localhost:8000/index.html" in Chrome and Firefox (and presumably any browser with HTML5 mode capabilities), it works as expected, with the navigation clicks causing the proper template to be loaded into the ngView (according to the routeProvider).

However, when I run it in IE 9 (and maybe other non-HTML5 mode browsers), I get the "10 digest() iterations reached" problem (see log/ie9.error-console.txt for the copy from the IE 9 "F12 Developer Tools" console).

After looking at the source code, I saw why the max iterations were reached...the oldUrl (which comes from location.href via the browser.url() getter) does not have the hash (or hashbang) but the location.absUrl() does have it and thus they're always considered different here:

    $rootScope.$watch(function $locationWatch() {
      var oldUrl = $browser.url();
      var currentReplace = $location.$$replace;

      if (!changeCounter || oldUrl != $location.absUrl()) {

But, inside the browser url() function (setter behavior in particular), nothing happens because it thinks the old and new values are the same, because it compares the input url with the lastBrowserUrl rather than the location.href.

  self.url = function(url, replace) {
    // setter
    if (url) {
      if (lastBrowserUrl == url) return;

So, I think that's the first problem...I don't know enough about the framework or the specific intended behavior to know what should happen, but it seems like the watch should be able to recognize that no changes happened when html5Mode is set to true for a browser like IE 9 that does not support it.

I put in a "fix" to stop this unintended iteration (etc/angular.js.patch) and this got rid of the error in the console but still did not load the index.html and this did not allow me to try the navigation links. I think this is the second problem; however, it could be because I didn't fix the first problem properly.

Finally, thanks for all of your work on this fine product (and sorry for the formatting of parts of this message).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions