我尝试在另一个类中转换对象,但是当我尝试访问属性对象时,我得到了未定义的信息。
假设有这个:
elemSelect: ExampleClass //this class has a different properties like id , cod etc...
label: 'Ana', icon: 'pi pi-fw pi-refresh', command: (event: Event) => {
console.log(this.elemSelect); //it prints the correct value
this.router.navigate(['/home'], { queryParams: { elem: this.elemSelect},skipLocationChange: true })
}
现在在我的.ts文件中
this.activatedRoute.queryParams.subscribe(params => {
this.details=params['elem'];
console.log(params['elem'].id); //it prints me undefined
});
当我在查询参数中传递对象时,控制台会从elemSelect
向我打印正确的值,但是当我从查询参数中获取对象时,它将打印我未定义的值。有人可以帮助我吗?