-
Notifications
You must be signed in to change notification settings - Fork 27.5k
IE9 error with ng-click and no href #7721
Comments
I ended up checking that |
Sure thing. |
Apparently plnkr.co doesn't support IE9, and I couldn't get JSFiddle to do what I wanted; apologies. I tried
|
Maybe I can provide a little more info, just tested this IE8, IE9, they both have this problem. Angular is trying here to make relative links work in HTML5 mode for legacy browsers and is flipping over the following lines of code:
This is in the $location#$locationChangeSuccess (somewhere around line 9751) I think the preferred way here is to use $event.preventDefault or stopPropagation because you don't want the URL to change and don't want the $locationChangeStart, $locationChangeSuccess events to fire. Maybe this helps to get more insight. |
Or maybe angular should give you a better warning when trying this entanglement. |
I'm running into this too. Adding |
I add jsanders's workaround which cleared the issue in Chrome and IE10 for me. |
In IE9, with hashbang mode enabled, and having injected the
$location
service (not just configured the provider), an anchor with anng-click
but nohref
causes an exception when clicked:To reproduce, put this in a file named
ie9
and runpython -m SimpleHTTPServer 5000
, then visithttp://localhost:5000/ie9/
.Note that you must inject
$location
to see the issue; the offending line is in $location and is only run when the service is instantiated.There are several ways to "solve" the problem, but I'm not sure which is best. It seems that the implementation of the
a
(anchor) directive couldstopPropagation
as well as preventing default, or we could simply check for empty/undefinedhref
attributes at that point in$location
.The text was updated successfully, but these errors were encountered: