按钮元素上的routerLink不起作用

时间:2018-02-25 14:55:46

标签: javascript angular typescript angular-ui-router angular-routing

我有一个仪表板,其中包含来自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>
  
&#13;
&#13;
&#13;

我已经在app.module.ts中导入了这个

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

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

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

1 个答案:

答案 0 :(得分:0)

[routerLink]="['/employee/employee/]“您的路由器链接与您的路由不匹配,应该像{path:'employee/:id',component:EmployeeInfoComponent},。而且您错过了单引号。 试试这个[routerLink]="['/employee/, item.key]”

相关问题