-
Notifications
You must be signed in to change notification settings - Fork 27.5k
cancelling routes #2109
Comments
Locationchangestart event should do the trick if it doesn't then that's a bug. Can you repro this? |
I'm playing around with simulating a back button in the $location.url() // 'somePath'
$window.history.go(-1);
$location.url() // 'somePath' still
$window.history.back();
$location.url() // 'somePath' still Maybe that's part of the problem. |
Any idea when this will make into one of the "unstable" builds? This is a show stopper when a controller needs to track dirty data and prevent navigation away from a view (or at least prompt the user). Thanks for the fix though quazzie. |
Before $locationChangeStart event is not broadcast when pressing the back-button on the browser. Closes #2109
Calling $route.reload() in $routeChangeStart seems to prevent the route from changing. |
The event $locationChangeStart has as it's second parameter the 'next' route but all it shows is the full path: "http://localhost:3000/#/users" Surely if you expect people to use this to cancel routes it should include only the /users (for example) part of the path as $routeChangeStart event does with it's 'originalPath' property. Right now we're forced to parse the URL to use this. These inconsistencies need to be cleaned up, they make it a nightmare to learn angular. |
I tried $route.reload in $routeChangeStart but it seems to cause a loop and the page freezes (Angular 1.2.7). |
@nickspacek I had the same problem. I resolved it by injecting As @WhatFreshHellIsThis mentioned there are inconsistencies with the arguments for In my case, on The downside to my |
I'm having a similar issue where I want to authenticate the route change by examining the sugared next parameter and cancelling the route change in the case where the user isn't authorized. This seems like a very basic feature that should have a clean solution. |
|
as @zulrang said - I'm trying to do the exact same thing... big time bummer. |
@OakBehringer can't you just add a |
We do this. I added a provider which the resolve property of the router utilizes. It tests a variety of auth conditions and either redirects the user to their destination or back to the login screen. We apply this provider to all routes and use API header authentication, combined with Rails sessions to allow a session to persist over multiple visits. At least... I think that's what we have, I'm definitely a UI guy. |
Nothing helps me for v0.2.18. |
There is currently no good/documented way of canceling a route change.
event.preventDefault()
can be used with$locationChangeStart
but that event doesn't fire from the back button (bug?)$routeChangeStart
does fire on back button, but itspreventDefault()
method doesn't actually prevent the route from changing (bug?)Related issues: #592 #665 #1569
The text was updated successfully, but these errors were encountered: