I would redirect user to another page when he clicks on a datatable row
In HTML
<p-table [value]="users" selectionMode="single" [(selection)]="selectedUser" dataKey="uid" (onRowSelect)="selectedUserDetails($event)" styleClass="tab-result">
in TS file
selectedUserDetails(userDetails) {
console.log(userDetails);
console.log("enterhere"); // is printed on console dev
this.router.navigate['/userdetails'];
}
In module routing
const routes: Routes = [
{
path: "",
component: AdministrationComponent,
children: [
{ path: "", component: ResulTabComponent, pathMatch: "full" },
{ path: "userdetails", component: UserDisplayComponent }
]
}
];
For information administration route is lazy loaded on this path http://localhost:4200/administration
userdetails should be http://localhost:4200/administration/userdetails
In administration component
<router-outlet></router-outlet>
My problem is that when clicking I don't get redirected to the userdetails
page but when I navigate to /userdails from url bar I see the component