代码之家  ›  专栏  ›  技术社区  ›  Mohamed Ali Lassoued

按钮元素上的routerLink不工作

  •  0
  • Mohamed Ali Lassoued  · 技术社区  · 7 年前

    我有一个仪表板,其中包含来自firebase的一些信息 我有一个这样的按钮(更多) enter image description here

    当我点击它时,它不起作用,也无法将我重定向到我的特定页面 这是html文件中的我的代码

    <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>
      

    我已将此导入应用程序。单元ts

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

    我还在路由配置中添加了这个

    {path:'employee/:id',component:EmployeeInfoComponent},
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   Suhag Lapani88    7 年前

    [routerLink]="['/employee/employee/] “您的routerLink与您的路线不匹配,应该是这样的 {path:'employee/:id',component:EmployeeInfoComponent}, . 你错过了单引号。 试试这个 [routerLink]="['/employee/, item.key]”