Reputation: 37
In my project on Angular 5, routing config looks like this:
const routes: Routes = [
{
path: 'a',
component: MainComponent,
children: [
{
path: 'ab',
component: ABComponent
},
{
path: 'ac',
component: ACComponent
}
],
data: AData // array of objects
},
{
path: 'b',
component: MainComponent,
children: [
{
path: 'bb',
component: BBComponent,
data: BBData // array of objects
},
{
path: 'bc',
component: BBComponent,
data: BCData // array of objects
}
],
data: extraData // if I put it on, extraData will be both in BBComponent and BCComponent
}
];
In theory, BBData should passed on BBComponent, and BCData on BCComponent, but object this.route.snapshot.data (this.route instance of ActivatedRoute) is empty. For path 'a', data passed in both component successfully.
I have not idea how to fix it, please, help me.
Upvotes: 1
Views: 1654