假设我有一个嵌套的 itemListComponent,它是 rootComponent 的子组件,使用以下模板:
<span *ngFor="#item of list">
<a [routerLink]="[item.url]">{{item.title}}</a> |
</span>
由 Json 服务提供的路径 item.url 可能具有以下路径结构之一:
- /category1/(内容 id)/(用破折号 (-) 连接的标题)
- /category2/(内容 ID)/(用破折号 (-) 连接的标题)
- /category3/(内容 ID)/(用破折号 (-) 连接的标题)
例子:
category2/987654/hello-world
category2/123456/hi-teacher
category3/554433/yo-brother
如何实现 @RouteConfig 以便这些链接使用 itemDetail 组件?
抱歉,如果这看起来不是很详细。我没有找到由具有完整路径(非组装路径)的服务提供的路由 url 的明确操作指南
尝试这个:
<span *ngFor="#item of list">
<a [routerLink]="['/category', item.url]">
{{item.title}}
</a>
</span>
路线.ts:
{path: "category/:id", component: CategoryComponent}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)