Angular 路线中的角度通过数据
我用这种方式传递数据Angular 路线中的角度通过数据,angular,typescript,Angular,Typescript,我用这种方式传递数据 console.log(this.regForm.value); //there is data this._router.navigate(["/tsafety/checklist-checks"], this.regForm.value); 在带有路由检查表的组件中,我尝试使用 constructor(private route:ActivatedRoute) { this.route .params .subscribe(params =&
console.log(this.regForm.value); //there is data
this._router.navigate(["/tsafety/checklist-checks"], this.regForm.value);
在带有路由检查表的组件中,我尝试使用
constructor(private route:ActivatedRoute)
{
this.route
.params
.subscribe(params => {
this.truckdetails = params; //this is never set
console.log(params);// this is empty
});
}
每当我试图访问此.truckdetails时,它总是空的
获取传递的数据还需要添加哪些内容?您应该尝试使用this.route.snapshot.data['yourdata']
您应该尝试使用this.route.snapshot.data['yourdata']访问数据。
导航不正确。可选参数(如您正在传递的表单数据)应位于方括号内。函数的第二个参数获取有关导航的额外信息。见:
你的代码应该是
this._router.navigate(["/tsafety/checklist-checks", this.regForm.value]);
导航不正确。可选参数(如您正在传递的表单数据)应位于方括号内。函数的第二个参数获取有关导航的额外信息。见:
你的代码应该是
this._router.navigate(["/tsafety/checklist-checks", this.regForm.value]);
我在项目中使用switchMap
this.route.params
.switchMap((params: Params) => {
console.log(params);
});
我在项目中使用switchMap
this.route.params
.switchMap((params: Params) => {
console.log(params);
});