我正在尝试使用角度2创建一个应用程序。我想将数据发送到我班级的路由。
代码
@RouteConfig([
{
name: 'Slider',
component: thumbnail_gallery ,
path: '/slider/:id' ,
data : model
}
])
export class Watch extends Ext implements OnDestroy{
public model: any; <=== i want pass this from route
}
我该怎么做?
答案 0 :(得分:1)
试试这个: -
@RouteConfig([
{name: 'Slider', component: thumbnail_gallery ,path: '/slider/:id' , data : model }
])
export class Watch extends Ext implements OnDestroy{
public model: any;
constructor(private router: Router){}
Demorouting(){
this.router.navigate(['/slider', {id: this.modal}])
}
}