I have defined some route data in my app routing module like below:
const appRoutes:Routes = [
{path: \'\', component: LoginComponent, data:[{PageName:
If you are willing to wait until the ngAfterViewInit event you can link to the router outlet using viewchild.
i.e.
@ViewChild('router')
private routerOutlet: RouterOutlet;
ngAfterViewInit() {
this.routerOutlet.activateEvents
.pipe(
map(() => this.routerOutlet
.activatedRouteData
)
)
.subscribe((data) => {
// Code
});
}