R
R
Roman Rakzin2022-01-25 00:11:37
Angular
Roman Rakzin, 2022-01-25 00:11:37

Is there a way to know that the angular route is gone?

I want to know that they switched to the route and left it.
Usually in the main component from the loadable module I find out when creating, and when destroying.
Later I began to add a resolver when they switch to the route.
But how do I know that they left the route?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mikhail Osher, 2022-01-25
@miraage

The resolver should not know that the page has been left. Its task is to accept some data, and return others.

L
Lan_ser, 2022-01-27
@Lan_ser

try Location

V
Vitaly Kadyrov, 2022-01-31
@Ahmad66617

To do this, the router has Observable events - where there is, for example, NavigationEnd -> more details in the docks ( https://angular.io/api/router/RouterEvent ) - where you can subscribe and through RxJs operators not only track, but combine any case and actually react to it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question