Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 路线中的角度通过数据_Angular_Typescript - Fatal编程技术网

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);
});