Angular2(RC-4):无法读取属性' pathsWithParams'未定义的

时间:2016-07-30 11:35:39

标签: angular routing

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

  

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

我的路由文件包含

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 }
    ]},
]

任何想法?

更新

每当我在html端使用routerLinkActive

时,问题就会出现问题

1 个答案:

答案 0 :(得分:2)

得到了答案,谢谢@micronyks

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

所以正确的语法是:

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