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.

Infinite digest when replacing $location.hash() #10228

Closed
@pkaminski

Description

@pkaminski

This appears to be a regression in v1.2.27 probably caused by #9470 (@tbosch); v1.2.26 (and earlier, probably at least back to v1.2.24) does not exhibit the problem. The details:

I'm running $locationProvider in html5Mode. In a controller bound with ng-route I have the following code very near the top of the constructor:

  if ($location.hash()) {
    $rootScope.hash = $location.hash();
    $location.replace();
    $location.hash('');
    return;
  }

This is meant to squirrel away the hash and remove it from the URL, causing the controller to be reloaded. What ends up happening in v1.2.27 (in both Chrome 39 and Firefox 33.1.1) is that $browser.url() calls location.replace() but no longer sets reloadLocation because sameBase is true. However, location.href keeps returning the original URL with the hash, causing $locationWatch to spin and keep issuing $browser.url() calls, which are no-ops because lastBrowserUrl is already stripped of the hash. Then everything comes crashing down with an infinite digest error.

It's entirely possible that I'm doing something wrong, in which case I'd really appreciate a hint as to what that might be. Thanks!

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions