I have to find whether a page is refreshed or it is loaded because of some routing.
I think it's possible using Angular Router's NavigationEnd event by subscribeing to the router events.
Anyone knows how to do it?
No pure javascript solutions, please.
Sure, you can use it like this:
eventsObservable on theRouterinstance.NavigationEnd. You can achieve it using Rxjs'sfilteroperator.NavigationEnd, you will get an event object which would be of typeNavigationEnd. This has properties likeurlAfterRedirectsandurlthat you can leverage to understand if the routing action resulted in navigation to a particular component.NavigationEndevent won't fire. So if that fires, you can be sure that it was a situation of a page being routed into.Something along the lines of this:
Here's a Sample StackBlitz for your ref.
PS: To confirm on the 4th point, just try pressing the reload button on the StackBlitz's View Mode and then check if anything gets printed on the console. Since this a reload, nothing will get printed. This can be considered as a certainty for a refresh/reload situation.