Reputation: 15214
Could you give me an example how to get data from Routes. Routing & Navigation
const appRoutes: Routes = [
{ path: 'crisis-center', component: CrisisListComponent },
{ path: 'hero/:id', component: HeroDetailComponent },
{
path: 'heroes',
component: HeroListComponent,
data: { title: 'Heroes List' } // <--- How to use this data?
},
{ path: '',
redirectTo: '/heroes',
pathMatch: 'full'
},
{ path: '**', component: PageNotFoundComponent }
];
Thank you
Upvotes: 0
Views: 678
Reputation: 4324
You can use ActivatedRoute
in your component/service constructors.
For example:
public class MyAppComponent{
data: any;
constructor(route: ActivatedRoute){
this.data = route.snapshot.data;
}
}
You can find more details here.
Upvotes: 2