首页 > 解决方案 > 在控制台上获取错误数据

问题描述

我只是将一些数据作为 url 传递并尝试从 URL 控制下一页。但是在错误的变量中获取数据。

供应商-action.component.html

<tr mat-header-row *matHeaderRowDef="['nVendorId','change_column','change_type','Timestamp','status','requestid']"></tr>
 <tr class="rowhover" (click)="displayData(row.change_column,row.nVendorId,row.requestid)" mat-row *matRowDef="let row; columns: ['nVendorId','change_column','change_type','Timestamp','status','requestid']"></tr>

供应商-action.component.ts

displayData(col,id,rid)
{
 this.router.navigate(["/home/vendor-action/approval",col,id,rid]);
}

批准.component.ts

ngOnInit() 
  {
    this.col=this.activatedRoute.snapshot.paramMap.get('col');
    this.id=this.activatedRoute.snapshot.paramMap.get('id');
    this.rid=this.activatedRoute.snapshot.paramMap.get('rid');

    console.log(this.col);
    console.log(this.id);
    console.log(this.rid);
  }

我在“col”中得到“rid”的值,在“id”中得到“col”,在“rid”中得到“null”。为什么会这样。这有什么问题吗?

标签: angular

解决方案


在您的路由信息​​中添加这 3 个变量


推荐阅读