将数据从我的班级传递到路线

时间:2016-05-28 08:48:58

标签: javascript angularjs angular slider swiper

我正在尝试使用角度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
}

我该怎么做?

1 个答案:

答案 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}])
    }

}