Angular2(RC-4):无法读取未定义的属性“ pathsWithParams” [英] Angular2(RC-4) :Cannot read property 'pathsWithParams' of undefined

查看:74
本文介绍了Angular2(RC-4):无法读取未定义的属性“ pathsWithParams”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在angular2 RC-4中使用子路由时出现此错误

while using child routing in angular2 RC-4 getting this error


无法读取未定义的属性'pathsWithParams'

Cannot read property 'pathsWithParams' of undefined

我的路由文件包含

export const routes: RouterConfig = [
  { path: '', component: HomeComponent },
  { path: 'demo', component: DummyComponent },
  { path: 'user-profile', component: UserProfileComponent,
    children:[
      { path: '', component: ProfileOverview },
      { path: 'smart-points', component: ProfileSmartPoints }
    ]},
]

有什么主意吗?

只要我使用 routerLinkActive 在html端

The problem is actully whenever i use routerLinkActive in the html side

推荐答案

得到了答案,谢谢@micronyks

Got the answer thanks @micronyks

实际上是我们必须使用属性 [routerLinkActiveOptions] = {exact:true} ,同时使用
routerLinkActive = html中的 active-link ,用于检查活动路径。

actually the probelm is we have to use the property [routerLinkActiveOptions]="{exact: true}" while using routerLinkActive="active-link" in the html for checking active route.

因此,正确的语法是:

<a routerLinkActive="active" [routerLinkActiveOptions]="{exact:true}" [routerLink]='["./Dummy"]'>Dummy</a>

这篇关于Angular2(RC-4):无法读取未定义的属性“ pathsWithParams”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆