You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
As discussed here on google groups, Leo Cavalcante points out that when the $location dependency is injected, IE8-9 acts strangely and somehow reloads the page, instead of preventing the default action as is expected on a click on an anchor with the ng-click directive. I forked his fiddle and made another one which shows the problem in a more obvious way:
On initial run, the value in the textbox is 'initial', then after the click on the link it gets changed to 'test', but is reverted back to 'initial' automatically because of this bug. If we remove the $location dependency and re-run the fiddle, it works as expected. I don't have IE8, but I have this problem on IE9 / Win7.
Hopefully this is not a duplicate, I did check the issues marked as bugs and did not find this.
Martin
EDIT: This is with AngularJS 1.0.1 by the way, as can be seen in the fiddle.
The text was updated successfully, but these errors were encountered:
Workaround in the mean time: send $event as argument to the ng-click method, and call $event.preventDefault() manually. Seems to work, see this fiddle:
My workaround is :
For me, the problem is : when you use href='#' or href='javascript:void(0)' in an anchor,
$browser.url() has an # or ? at the end. by remove the # or ?, it will not trigger the url change event.
diff -r 0c10cf25fe41 htdocs/js/angular.js
--- a/htdocs/js/angular.js Sat Nov 24 09:46:30 2012 -0500
+++ b/htdocs/js/angular.js Sun Nov 25 10:06:01 2012 -0500
@@ -5434,7 +5434,11 @@
var changeCounter = 0;
$rootScope.$watch(function $locationWatch() {
var oldUrl = $browser.url();
-
+ if (! isNaN(msie))
+ {
+ // remove last # or ? in oldUrl.
+ oldUrl = oldUrl.replace(/\?$/, '').replace(/#$/, '')
+ }
if (!changeCounter || oldUrl != $location.absUrl()) {
changeCounter++;
$rootScope.$evalAsync(function() {
As discussed here on google groups, Leo Cavalcante points out that when the $location dependency is injected, IE8-9 acts strangely and somehow reloads the page, instead of preventing the default action as is expected on a click on an anchor with the ng-click directive. I forked his fiddle and made another one which shows the problem in a more obvious way:
http://jsfiddle.net/Tg2Hs/5/
On initial run, the value in the textbox is 'initial', then after the click on the link it gets changed to 'test', but is reverted back to 'initial' automatically because of this bug. If we remove the $location dependency and re-run the fiddle, it works as expected. I don't have IE8, but I have this problem on IE9 / Win7.
Hopefully this is not a duplicate, I did check the issues marked as bugs and did not find this.
Martin
EDIT: This is with AngularJS 1.0.1 by the way, as can be seen in the fiddle.
The text was updated successfully, but these errors were encountered: