I am playing with Angular 2.0\'s new router and I try to use something similar to Angular 1.X ui-router / ng-route resolve mechanism.
I was trying to a
You have to move your @RouteConfig into the AppCmp constructor:
//@RouteConfig([
// { path: '/', component: HomeCmp, as: 'Home', data: this.history },
// { path: '/about', component: AboutCmp, as: 'About' }
//])
export class AppCmp {
history: string[] = [];
constructor(public list: PersonalizationList,
private router_: Router) {
list.get('histoy', (response) => {
this.history = response;
});
router_.config([
{ path: '/', component: HomeCmp, as: 'Home', data: this.history },
{ path: '/about', component: AboutCmp, as: 'About' }
]);
}
}
On the console output I could see:
RouteData {data: "test sample"}
Hope it helps!