Open khaled-su opened 9 years ago
Have a look at the livecycle hooks. In your case, the can(de)Activate hooks. Not exactly the same tough.
However, if you really need this, you can create an service that monitors $location and spawns events/callbacks when needed.
Not too sure if this is something I want in the new router tough.
Late to the party but playing with new router which is to say scouring source quite heavily at the moment. Basically as @SanderElias mentions I think a $watch is the answer here based on how the new router works. What's missing of course is due to the newness, documentation.
Anyway doing a $watch of $location.path() is exactly how the RootRouter kicks things off anyway. Probably don't even need a service could likely live in the RouterController.
Once some examples are out there I think this concern largely goes away. Add to that since EventEmiiters are not used all over the place, the sugar in 1.x ($routeChangeStart etc) that merely said hey I stated or stopped via broadcasts may be now out of place.
Feel feel to correct me if I've missed something, however this is how I see it I investigate the new router.
Hello,
I'm trying to implement logic which scrolls to the top of the page whenever the route changes, I used to achieve this by listening to the routeChangeStart event but its not there any more in the new router .. Any solutions?
Thanks.