我想通过 routeparams 使用 angular 5 将对象发送到另一个页面,但它不起作用。
看看我在下面写的代码:
<button mat-raised-button [routerLink]="['./view-class-timing-set',newObject]">New</button>
对象的 TS 代码:
newObject = {
id: 123
}
模块代码:
{
path: 'ng2/ClassTimingSet',
component: ClassTimingSetComponent,
children: [
{ path: '', component: NewClassTimingSetComponent},
{ path: 'view-class-timing-set/:newClassTimingObj', component: ViewClassTimingSetComponent}
]
},
路由页面后显示对象的 TS CODE:
ngOnInit() {
this.route.params.subscribe(
params =>{
console.log('THis is the object that I got');
console.log(params);
}
)
}
但是,页面没有被路由它说:
Cannot match any routes. URL Segment: 'ng2/ClassTimingSet/view-class-timing-set;id=123'