angular - 无法导航到另一个组件 - Angular
问题描述
我有 3 个组件从第一个移动到第二个。但是从第二个开始,我无法浏览第三个组件。
Name
仅显示超链接,但单击时没有任何反应。
这是第二个组件代码
<table>
<tr *ngFor="let lst of devices; let i = index" border="1">
<td>{{lst.DeviceId}}</td>
<td>{{lst.LastJobStatus}}</td>
<td> <a routerLink="deviceapps">{{lst.Name}}</a> </td>
</tr>
</table>
App-routing.module.ts
班级
const routes: Routes = [
{ path: 'devicelist/:id', component: DeviceListComponent } ,
{path: 'deviceapps',component: DeviceAppsComponent}
];
第三部分代码
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router, ParamMap } from '@angular/router';
@Component({
selector: 'app-device-apps',
templateUrl: './device-apps.component.html',
styleUrls: ['./device-apps.component.css']
})
export class DeviceAppsComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
解决方案
看起来您在内部使用相对路径,因此请尝试编写绝对路由,例如:
<a [routerLink]="'/deviceapps'">{{lst.Name}}</a>
推荐阅读
- r - 在 R 中,我如何重新编码 LCA 的调查,所以第一个响应是 1,而不是 0?范围现在是 0-4
- regression - 具有不同长度的解释变量的 OLS 回归
- datagrip - DataGrip 导航栏“输入”点击打开控制台而不是展开文件夹
- python - 为什么它显示“错误”而不是“好”?
- typescript - 用户单击时如何更改 .svg 图标或图像颜色。在世博会上反应天真
- python - 从 Python 列表分配中的列表中删除重复元素
- amazon-web-services - 将所有卷修改为 gp3 aws ec2
- r - R中的绘图错误:需要有限的'ylim'值
- html - 在 div 中移动 2 个元素
- r - ggplot2 错误:输入无效:date_trans 仅适用于 Date 类的对象