Reputation: 355
I need to do some stuff within the route definition, when the lazyloaded module is loaded. The route has a resolver UserDataResolverService, how can I access the resolved data within the route definition?
{
path: 'path-a',
resolve: { userData: UserDataResolverService},
loadChildren: () =>
import('./pages/my.module').then((m) => {
// access resolved data here: userdata.details
return m.MyModule;
}),
}
Upvotes: 0
Views: 159
Reputation: 3570
You can simply inject ActivatedRoute
in your child component and then use
constructor(private route: ActivatedRoute) {
console.log(this.route.snapshot.data['userData']);
}
Upvotes: 1