单击垫子行后如何布线 table
How to route after clicking row of mat table
单击垫子行后我无法布线 table。它没有显示任何错误。在 URL 中,路径正在像这样从“http://localhost:4200/vendor-list" to "http://localhost:4200/vendor-list/vendor”正确更改。但显示的是同一页 (table)。下面我附上了我的代码,如果我在这方面做错了什么,有人能帮忙吗
vendorlist.component.html
<tr mat-header-row *matHeaderRowDef="ordersDisplayedColumns"></tr>
<tr (click)="displayData(row)" mat-row *matRowDef="let row; columns: ordersDisplayedColumns;"></tr>
vendorlist.component.ts
export class VendorlistComponent implements OnInit {
constructor(private router:Router) { }
displayData(row)
{
console.log(row);
this.router.navigate(["/vendor-list/vendor/"]);
}
}
myroute.module.ts
{path:'vendor-list',component:VendorlistComponent,canActivate:[AuthguardGuard],
children:[
{path:'vendor',component:VendorComponent,canActivate:[AuthguardGuard]
]}
为了测试,我将选择器放在 table 之前。然后该页面正在显示,但在我的页面下方,也显示了与上一页相同的 table
您必须如下更改路由:
{path:'vendor-list',
children:[
{path:'vendor',component:VendorListComponent,canActivate:[AuthguardGuard]},
{path:'vendor',component:VendorComponent,canActivate:[AuthguardGuard]}
]}
如果要更改完整内容,您需要在子数组中添加父组件作为“”路径。
如果你想使用来自父组件的一些内容,那么你必须使用 router-outlet 并且你的配置很适合。
单击垫子行后我无法布线 table。它没有显示任何错误。在 URL 中,路径正在像这样从“http://localhost:4200/vendor-list" to "http://localhost:4200/vendor-list/vendor”正确更改。但显示的是同一页 (table)。下面我附上了我的代码,如果我在这方面做错了什么,有人能帮忙吗
vendorlist.component.html
<tr mat-header-row *matHeaderRowDef="ordersDisplayedColumns"></tr>
<tr (click)="displayData(row)" mat-row *matRowDef="let row; columns: ordersDisplayedColumns;"></tr>
vendorlist.component.ts
export class VendorlistComponent implements OnInit {
constructor(private router:Router) { }
displayData(row)
{
console.log(row);
this.router.navigate(["/vendor-list/vendor/"]);
}
}
myroute.module.ts
{path:'vendor-list',component:VendorlistComponent,canActivate:[AuthguardGuard],
children:[
{path:'vendor',component:VendorComponent,canActivate:[AuthguardGuard]
]}
为了测试,我将选择器放在 table 之前。然后该页面正在显示,但在我的页面下方,也显示了与上一页相同的 table
您必须如下更改路由:
{path:'vendor-list',
children:[
{path:'vendor',component:VendorListComponent,canActivate:[AuthguardGuard]},
{path:'vendor',component:VendorComponent,canActivate:[AuthguardGuard]}
]}
如果要更改完整内容,您需要在子数组中添加父组件作为“”路径。
如果你想使用来自父组件的一些内容,那么你必须使用 router-outlet 并且你的配置很适合。