-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Infinite loop of $locationWatch #2815
Comments
@dbinit Proposed I'd try the workaround angular.module('myApp', []).value('$anchorScroll', null); mentioned here. It did not work. Instead, I am getting another exception:
|
#1417 (comment) proposes that adding |
I can also recreate this in Firefox 19.0.2. |
This is my angular.module('addressbook', [])
.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/colleagues', {
templateUrl: 'partials/addressbook/colleagues.jsp',
controller: ColleaguesListController
})
.when('/colleagues/:contactId', {
templateUrl: 'partials/addressbook/colleagues.jsp',
controller: ColleaguesListController
})
.when('/external', {
templateUrl: 'partials/addressbook/externalcontacts.jsp',
controller: ExternalContactsListController
})
.when('/external/:contactId', {
templateUrl: 'partials/addressbook/externalcontacts.jsp',
controller: ExternalContactsListController
})
.when('/contacts/:contactId', {
controller: ContactsForwardingController,
template: "Forwarding you to the right contact..."
})
.otherwise({redirectTo: '/colleagues'});
}])
... Loading the page with the |
I have now isolated what triggers the <div data-ng-controller="MyVoicemailController" data-ng-include src="'/partials/desktopimitation/voicemail.jsp'">
</div> I also set the content of I'll see if I can reproduce this in a minimum viable example. |
I inlining |
I tried, once again, to reproduce the issue here: https://gist.github.com/JensRantil/5670869 Unfortunately, I couldn't. I'm closing this issue. Reopen, if anyone has additional information. |
I should also be mentioned that inlining |
I had the exact same issue. Using the the "debugger;" statement, I looked at the call stack. I noticed calls into the JQuery library. I removed JQuery and it worked fine. |
Interesting. Out of curiousity, what jQuery version were you using? I'll post what version we are using tomorrow when I'm at work. |
I was using JQuery 1.8 it was the default with middleman |
I was using jQuery 1.7.2 and jQuery UI 1.8.11 (custom). |
Unfortunately taking jquery out entirely is not an option for me. I've temporarily resolved this by monkey patching the watch on $locationWatch in angular js from: if ((!changeCounter || oldUrl != $location.absUrl()) { to if ((!changeCounter || oldUrl != $location.absUrl() && ($location.absUrl()+'#')!=oldUrl)) { Obviously if your right separator is not '#', you will need to change the above line. If anybody has any insight into how to solve this in a more sustainable manner, I'm all ears |
I'm getting the same error with Angular version 1.1.4. I removed jQuery and the problem goes away. I'm using jQuery version 1.9.1. |
@apolishch Your solution doesn't work for me, but it looks like a similar solution to one presented in #3915 does wok.
to check if jQuery is present. And near line 11256 I changed
into
Of course it means that history API wont be used anymore. |
Reversing that commit greatly reduced the frequency at which this had been happening with my app - thanks @burakaltundal. However, I'm still experiencing same looping condition in kind of a spontaneous fashion that's difficult to reproduce. In the same way, there's browser freezing and console output referring to a $digest() loop caused by $locationWatch. |
Had same problem. This link had a solution: Basically use |
@jimdoyle82 you are right but $location.path("/home"); will not fix the problem on some mobile platforms(and maybe some others too) as we have tested. Because of that we switch conditionally between $location.path("/home"); and location.hash |
And $location.path() doesn't permit navigating outside of the Angular base path (the given path must begin with '/'). |
Faced the same issue when using window.history API with angular routing. in angular v1.2 rc3 |
Below commit may be the solution If you are faced the same issue when using history api in angular v1.2.x |
I am getting this on the latest version of angularjs also when I use ng-include in my code |
@chaudhary can you make a plunkr or jsfiddle in a new issue demonstrating your problem? Thanks! |
I have exactly the same issue listed here. I am using AngularJS 1.2.10. I tried to create a plunkr with a code snippet that I have in my project: http://plnkr.co/edit/1jLBAuwvl8RIDKrVFvjS but am not able to see any of the text box from the ng-include src. I see the looping problem in chrome |
@kavuri is there a chance you are bootstrapping your app twice? both programatically and through use of |
I have the same issue. My code before fix |
@scoolboy true, when I had "/" before the directory, it works. Interestingly, if I have a subdirectory under "/partials", like "/partials/graphs/graph.html", then I get errors. Did you happen to face any such problem? |
@kavuri no i dont have any problems with this case. |
I also experienced this. Complicated to figure out what happens. related to adding this:
sorry I can't isolate it more. dragons be here. |
Version: 1.2.2 I noticed that if I entered the page with a hash sign and clicked the element the hashsign got removed, and vide versa. (http://localhost# <-> http://localhost) Finally I tracked down the issue which was that the click event bubbled up to $rootElement and triggered a click listener defined in http://ajax.googleapis.com/ajax/libs/angularjs/1.2.2/angular.js line 8928. It is unclear to me what that click listener does. The solution for me was to add event.preventDefault() in my own click listener. |
I sent an initial e-mail to the Google Groups mailing list here: https://groups.google.com/forum/?fromgroups#!searchin/angular/$24locationWatch/angular/Vihjqr04UUw/f3vIBtk9-IIJ I decided to create an issue to get this thing documented properly.
I have two AngularJS applications that individually functions correctly. One of them uses a
$routeProvider
to switch between views and the other does not. I just ran into a bug when having both applications on a single page; Switching from http://myurl.com/page.html#/one to http://myurl.com/page.html#/two triggers an infinite loop of$locationWatch
calls. Initially loading the page works fine.I am getting errors similar to #1417, but there are some differences:
<a href="#/two">link</a>
tag.Some additional information:
I've tried recreating this issue, but have so far failed: http://plnkr.co/edit/YSAHIocwCePqg8ZZig11
The text was updated successfully, but these errors were encountered: