-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Changing $location.path(newUrl) in $routeChangeStart #9607
Comments
Here is a workaround:
E.g.
See this plunker: http://plnkr.co/edit/Zg5wIfyHlfcG1XWyOZmC?p=preview A nicer way would be if the event had a function |
Perfect - thanks for the quick response Tobias. I completely agree on the redirectTo function but even without that I'm pretty psyched with the preventDefault() support you added so I'm good for now. :-) |
Same issue. Thank you for the workaround. |
wrapping it in $timeout works too. |
As noted by @shahata currently we don't have an extension point that would allow us to add new methods to an event, as all the events are created the same way: angular.js/src/ng/rootScope.js Line 1217 in 74981c9
So, implementing a solution suggested by @tbosch would be more involved. Looking at the @shahata alternative proposal (#9678) right now. |
…geStart Closes angular#9607 Closes angular#9678
I'm upgrading an app to 1.3.0 and was previously redirecting a user to a login page as needed when $routeChangeStart fired by calling $location.path('/login').
With 1.3.0 I see the ability to call preventDefault() now (nice addition), but that completely shuts off $location redirects (such as to a login view). $location.path('/login') does work (when preventDefault() hasn't been called) but it only changes the browser URL but not the view. What's the recommended way of doing a redirect now to another view within $routeChangeStart?
Here's an example of what I'm trying to do (pretty standard with older versions of Angular):
I'm assuming there's a different technique now for this type of task in 1.3.0?
The text was updated successfully, but these errors were encountered: