How can I pass a variable from my AppComponent to CoursesComponent using RouteConfig? The "data" property in route config seems to only accept constant parameters and cannot recognize "this". Is there a workaround for this limitation?
If not, what is the recommended approach for passing variables to routed components?
@Component({
selector: 'app',
template: `
<router-outlet></router-outlet>
`,
directives: [ROUTER_DIRECTIVES],
})
@RouteConfig([
{ path: '/courses'
, name: 'Courses'
,component: CoursesComponent
,data:{token:this.token}} // Attempting to access "token" here causes an error - cannot read property "token" of undefined
])
export class AppComponent {
token:string;
//I need to update the token (string) in this component and pass it to the routed components
}