webivan12016-01-25 21:38:47
webivan1, 2016-01-25 21:38:47

Angular2 How to hang an event on url change?

I want to hang an event for changing the url, in the first angular it was done very simply
$scope.$on('$locationChangeStart', () => {...})
, in the second I can’t find the information.
+ There is a problem with the router

    path: '/',
    component: Home,
    name: 'Index'
    path: '/about/',
    component: About,
    name: 'About'

Being on the /about/ page, I press F5, after updating the page, angular2 erases the slash at the end of the url, that is, it turns out /about
How to tell angular that it does not delete / ?
On the back, a similar url leads to 404, it must be present / at the end.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
webivan1, 2016-01-26

PlatformLocation.onPopState Fires an event when the browser button is clicked - back or forward.
You have to click on the link.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question