My module.ts,
import { NgModule } from \'@angular/core\';
import { BrowserModule } from \'@angular/platform-browser\';
import { RouterModule,Router } from
you can call activate method from main router-outlet like this
which will call every time when route will change.
Another way to achieve the same is to subscribe to the router events even you can filter them out on the basis of navigation state may be start and end or so, for example -
import { Router, NavigationEnd } from '@angular/router';
@Component({...})
constructor(private router: Router) {
this.router.events.subscribe((ev) => {
if (ev instanceof NavigationEnd) { /* Your code goes here on every router change */}
});
}