I have a route registered with some data:
const routes: Routes =
[
{path: \'my-route\', data: { title: \'MyTitl
This is part of my code (NOTE: I'm using Angular 8):
constructor(private _router: Router, private _route: ActivatedRoute) {}
ngOnInit() {
...
this.listenRouting();
}
listenRouting() {
this._router.events.subscribe((router: any) => {
routerUrl = router.url;
if (routerUrl && typeof routerUrl === 'string') {
routerList = routerUrl.slice(1).split('/');
console.log("data.breadcrumbs", this._route.snapshot.routeConfig.children.find(child => child.path === routerList[routerList.length - 1]).data.breadcrumbs);
...
}
});
}
So data is "hiding" under ActivatedRoute.snapshot.routeConfig.children Array. Each child contains, among other things, data. In my case data is configured in routing.module, e.g.:
const routes: Routes = [
{ path: "facility-datas",
component: FacilityTerminal,
data: {
breadcrumbs: "b ft"
}
},
...
];