Angular’s routing is an obserable, it subscribes to and publishes events whenever the routing changes. You can therefore use this event however you like.
There are 4 distinct steps in the life cycle of a routing event;
NavigationStart
RoutesRecognized
GuardsCheckStart
GuardsCheckEnd
ResolveStart
ResolveEnd
NavigationEnd
Here, I’ll use NavigationEnd.
In order for the app component to subscribe to the router, you must first inject the ROUTER class under the angular common router. Additionally, we’ll use some HMTL and CSS.