This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, this is my first PR ever so please let me know if did not do things the right way. I signed the CLA.
It's my attempt at fixing: #1699 and #592
This change adds support to calling
preventDefault()
on$route
's$routeChangeStart
event in order to cancel a change of route while leaving the browser's Url to its new location.This is different from calling
event.preventDefault()
on$location
's$locationChangeStart
because that reverts the browser's Url to its last Url.Basic usage
Example: Blocking a specific route change
Setup routes:
As you can see, I added a
path
attribute to my routes in order to compare them when$routeChangeStart
will be fired. You could instead give aname
such as "New Book" and "Existing Book" to your routes and compare using names.Cancel route:
In a controller, cancel route change when going from /Book/new to /Book/:d:
What do you think about this solution? Do you see any potential conflicts with other parts? Can you think of additional test cases I should write?