【问题标题】:How can I deal with child route with params in angular 2?如何处理带有角度 2 参数的子路由?
【发布时间】:2023-03-07 00:54:02
【问题描述】:

当我在我的 VideoComponent 中时,我的 URL 看起来像这样:app/video/9

这是问题所在,我想访问我的 EditComponent 当我点击一个标签(使用 routerLink)并像这样重写我的网址时:app/video/9/users/3

这是我的路线配置:

@RouteConfig([      
    { path: '/video/:video_id/users/:user_id', component: Edit, name: 'Edit'},
    { path: '/video/:video_id/', component: Video, name: 'Video'}
)]

最后是我的 routerLink :

[routerLink]=" ['Edit',{user_id:1}]"

我错过了什么?

【问题讨论】:

  • 这看起来您使用的是旧的和已弃用的路由器版本。您不使用最新路由器的任何原因?
  • Angular 2 RC1... 我正在开发管理仪表板模板,尚未更新。
  • 什么不起作用?你的routerLink 在哪里。也许您只需要在路由名称前加上..//

标签: url angular routes components


【解决方案1】:

好的,我只是忘记了我的孩子 EditComponent 中的指令:

directives: [RouterOutlet, RouterLink]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-16
    • 1970-01-01
    • 2016-04-08
    相关资源
    最近更新 更多