按钮元素上的 routerLink 不起作用
routerLink on button elements doesn't work
我有一个仪表板,其中包含来自 firebase 的一些信息
我有一个像这样的按钮(更多)
当我点击它时,它不起作用或将我重定向到我的特定页面
这是我在 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>
我已经在 app.module.ts
中导入了这个
import { RouterModule, Routes} from '@angular/router';
我还在路由配置中添加了这个
{path:'employee/:id',component:EmployeeInfoComponent},
[routerLink]="['/employee/employee/]
" 你的 routerLink 与你的路由不匹配,它应该像 {path:'employee/:id',component:EmployeeInfoComponent},
。你错过了关闭的单引号。
试试这个 [routerLink]="['/employee/, item.key]”
我有一个仪表板,其中包含来自 firebase 的一些信息
我有一个像这样的按钮(更多)
当我点击它时,它不起作用或将我重定向到我的特定页面 这是我在 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>
我已经在 app.module.ts
中导入了这个import { RouterModule, Routes} from '@angular/router';
我还在路由配置中添加了这个
{path:'employee/:id',component:EmployeeInfoComponent},
[routerLink]="['/employee/employee/]
" 你的 routerLink 与你的路由不匹配,它应该像 {path:'employee/:id',component:EmployeeInfoComponent},
。你错过了关闭的单引号。
试试这个 [routerLink]="['/employee/, item.key]”