routerLink on button elements doesn't work

Issue

I have a dashboard which is contain some information from firebase
and i have a button Like this (more) enter image description here

and when i click on it, it doesn’t work or redirect me to my specific page
this my code in html file

<table class="table table-inverse">
    <thead>
      <tr>
        <th scope="col">First Name</th>
        <th scope="col">Last Name</th>
        <th scope="col">Email </th>
        <th scope="col">Country</th>
        <th scope="col">City</th>
        
        <th scope="col">Salary</th>
        <th scope="col">ID</th>
        <th scope="col">Action</th>
      </tr>
    </thead>
    <tbody >
      <tr *ngFor="let item of employees">
        
        <th >{{item.firstName}}</th>
        <th >{{item.lastName}}</th>
        <th >{{item.email}}</th>
        <th >{{item.country}}</th>
        <th >{{item.city}}</th>
        
        <th >{{item.salary}}</th>
        <th >{{item.key}}</th> 
        <th> <a href="" [routerLink]="['/employee/employee/]" class="btn btn-primary">more <i class="fa fa-info-circle" ></i>
        </a></th>
      </tr>
    </tbody>   
  </table>
  

i have import this in the app.module.ts

import { RouterModule, Routes} from '@angular/router';

And also i added this in the route config

{path:'employee/:id',component:EmployeeInfoComponent},

Solution

[routerLink]="['/employee/employee/]” your routerLink not match with your routes it should be like {path:'employee/:id',component:EmployeeInfoComponent}, . And you missed close single quotes.
Try to this [routerLink]="['/employee/, item.key]”

Answered By – Suhag Lapani88

Answer Checked By – Pedro (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.