-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Router: Clicking on [router-link] directives bypasses native 'onHashChange' events #5013
Comments
There are two parts to this:
For 2, I think it makes more sense for your application to implement a directive. But if you don't have the option to compile the 3rd party templates, then intercepting hashchange events makes sense. Again, not sure this makes sense for all Angular apps, you might have to add a listener and add this to routing your self. We chatted about this in the past, but I'm still thinking through the ideal solution. I'll start work in earnest on this next week. |
Hi, Brian, we can't do this via a directive. We need something that works on a global scale (it's not reasonable to track down all required places and add such directive), and also that will notify us when the URL change is done by parts of the app that aren't managed by Angular. What we need is for the ng2 router to work seamlessly with the onhashchange, just like the ng1 router does right now: https://github.com/angular/route.dart/blob/master/lib/client.dart |
To be clear, yes, there will be the option to intercept this event seamlessly for your use case. It's just that the router also needs to support other cases as well. I wasn't disagreeing, just trying to fully capture the scope of this issue so that other developers with different needs aren't confused. |
Previously if the URL changed in `HashLocation` mode, the router would not pick up the change. This adds a listener in `HashLocationStrategy` for `hashchange` events to fix the problem. Closes #5013
Previously if the URL changed in `HashLocation` mode, the router would not pick up the change. This adds a listener in `HashLocationStrategy` for `hashchange` events to fix the problem. Closes #5013
I just landed a change for the third option in master. |
Thank you guys! 👍 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This makes it impossible for third-party code (not aware of Angular) to know when the route has changed. Honestly, I'd prefer for [router-link] to go entirely away or be optional. It's a lot easier and more portable to use plain
<a href="...">
and instead have the router deal with understanding those.For example, [router-link] only supports clicks. Not keyboard.
The text was updated successfully, but these errors were encountered: