Angular 8 - маршрутизация не произошла - строка таблицы матов - PullRequest
3 голосов
/ 04 апреля 2020

Я не знаю, почему моя маршрутизация не произошла после щелчка по строке. Ошибка не отображается. В URL-адресе путь меняется с "http://localhost: 4200 / vendor-list " на "http://localhost: 4200 / vendor-list / vendor " Но страница не меняется.

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, 
]},

Ответы [ 2 ]

1 голос
/ 10 апреля 2020
{path:'vendor-list',
 children:[
   {path:'vendor',component:VendorListComponent,canActivate:[AuthguardGuard]},
   {path:'vendor',component:VendorComponent,canActivate:[AuthguardGuard]}

 ]}

отметьте это, пожалуйста

0 голосов
/ 04 апреля 2020

Направление к уникальному идентификатору для каждой строки с использованием параметров URL.

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, 
]},
...