const APP_ROUTES: RouterConfig = [
{
path: 'app/home',
component: HomeComponent,
data: {
name: 'Home'
}
}
]
Assuming the route configuration is set as displayed above, how can one access the data
property from a certain directive?
@Directive({
name: 'hello'
})
class HelloDirective {
@Input('routerLink') link: string[];
ngOnInit() {
//HOW CAN I GET ROUTE AND ITS DATA FROM PATH/URL ???
//const magicallyGrabbedRoute = pleaseGiveMeMyRouteFrom(this.link);
//const myData = magicallyGrabbedRoute.data;
}
}
<a hello [routerLink]="['app/home']"> Go Home </a>
Within the hello
directive, what is the method to obtain the route configuration related to the value of the routerLink
attribute?