Angular 8 - 路由未发生 - 可能 table 行
Angular 8 - Routing not happend - Mat table row
我不知道为什么点击行后我的路由没有发生。
没有错误显示。
路径正在从“http://localhost:4200/vendor-list" to "http://localhost:4200/vendor-list/vendor”更改为 URL
但是页面没有变化。
vendorlist.component.html
<tr mat-header-row *matHeaderRowDef="ordersDisplayedColumns"></tr>
<tr (click)="displayData(row)" mat-row *matRowDef="let row; columns: ordersDisplayedColumns;"></tr>
</table>
vendorlist.component.ts
displayData(row)
{
console.log(row);
this.router.navigate(["/vendor-list/vendor/"]);
}
myrouting.module.ts
{path:'vendor-list',component:VendorlistComponent,
children:[
{path:'vendor',component:VendorComponent,
]},
使用 url 参数路由到每行的唯一 ID。
vendorlist.component.html
<tr mat-header-row *matHeaderRowDef="ordersDisplayedColumns"></tr>
<tr (click)="displayData(row, i)" mat-row *matRowDef="let row; let index as i; columns: ordersDisplayedColumns;"></tr>
</table>
vendorlist.component.ts
displayData(row, id)
{
console.log(row);
this.router.navigate([`/vendor-list/vendor/${id}`]);
}
myrouting.module.ts
{path:'vendor-list',component:VendorlistComponent,
children:[
{path:'vendor/:id',component:VendorComponent,
]},
{path:'vendor-list',
children:[
{path:'vendor',component:VendorListComponent,canActivate:[AuthguardGuard]},
{path:'vendor',component:VendorComponent,canActivate:[AuthguardGuard]}
]}
请检查这个
我不知道为什么点击行后我的路由没有发生。 没有错误显示。 路径正在从“http://localhost:4200/vendor-list" to "http://localhost:4200/vendor-list/vendor”更改为 URL 但是页面没有变化。
vendorlist.component.html
<tr mat-header-row *matHeaderRowDef="ordersDisplayedColumns"></tr>
<tr (click)="displayData(row)" mat-row *matRowDef="let row; columns: ordersDisplayedColumns;"></tr>
</table>
vendorlist.component.ts
displayData(row)
{
console.log(row);
this.router.navigate(["/vendor-list/vendor/"]);
}
myrouting.module.ts
{path:'vendor-list',component:VendorlistComponent,
children:[
{path:'vendor',component:VendorComponent,
]},
使用 url 参数路由到每行的唯一 ID。
vendorlist.component.html
<tr mat-header-row *matHeaderRowDef="ordersDisplayedColumns"></tr>
<tr (click)="displayData(row, i)" mat-row *matRowDef="let row; let index as i; columns: ordersDisplayedColumns;"></tr>
</table>
vendorlist.component.ts
displayData(row, id)
{
console.log(row);
this.router.navigate([`/vendor-list/vendor/${id}`]);
}
myrouting.module.ts
{path:'vendor-list',component:VendorlistComponent,
children:[
{path:'vendor/:id',component:VendorComponent,
]},
{path:'vendor-list',
children:[
{path:'vendor',component:VendorListComponent,canActivate:[AuthguardGuard]},
{path:'vendor',component:VendorComponent,canActivate:[AuthguardGuard]}
]}
请检查这个