Angular2(RC-4) :Cannot read property 'pathsWithParams' of undefined

…衆ロ難τιáo~ 提交于 2019-12-02 19:20:48

问题


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

Cannot read property 'pathsWithParams' of undefined

my routing file contains

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

any idea ?

update

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


回答1:


Got the answer thanks @micronyks

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.

so the correct syntax for this is :

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


来源:https://stackoverflow.com/questions/38673498/angular2rc-4-cannot-read-property-pathswithparams-of-undefined

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!