I have defined some route data in my app routing module like below:
const appRoutes:Routes = [
{path: \'\', component: LoginComponent, data:[{PageName:
Try to filter and loop your events instead of subscribe
constructor(router:Router, route:ActivatedRoute) {
router.events
.filter(e => e instanceof NavigationEnd)
.forEach(e => {
this.title = route.root.firstChild.snapshot.data['PageName'];
});
}
Please check the following working demo: https://plnkr.co/edit/rBToHRaukDlrSKcLGavh?p=info