2016-07-08 304 views
2

我試圖跟隨角2 DOC與角2路由的在-depht理解:https://angular.io/docs/ts/latest/guide/router.html#!#route-config角2路由器+角CLI

當我嘗試重定向爲默認頁解釋的那樣,打字稿編譯器給我這個錯誤:

Type '{ path: string; redirectTo: string; pathMatch: string; }' is not assignable to type 'Route'. 
    Object literal may only specify known properties, and 'pathMatch' does not exist in type 'Route'. 

這裏是我的代碼:

export const CrisisCenterRoutes: RouterConfig = [ 
    { 
    path: '', 
    redirectTo: '/crisis-center', 
    pathMatch: 'full' 
    }, 
    { 
    path: 'crisis-center', 
    component: CrisisCenterComponent, 
    children: [ 
     { path: ':id', component: CrisisDetailComponent }, 
     { path: '',  component: CrisisListComponent } 
    ] 
    }, 
    { 
    path: 'admin', 
    component: CrisisAdminComponent 
    }, 
]; 

我找不到這個明顯的問題作出任何解釋。代碼編譯時,我刪除'pathMatch'屬性。

非常感謝您的解釋。

回答

4

你是一個年紀大一點的版本。使用@angular/router版本應該是3.0.0-beta.2

+0

非常感謝我要瘋了;) – Valentin

+0

認真...從3.0.0-alpha.8更新到beta.2 ... UGH(intellij生成的模板) – Neikius