2016-10-12 10 views
1

を見つけることができません。角度2は、私は、単純なルーターを持っているデフォルトルータ

const routes = [ 
    { 
     path  : "", 
     component: AuthLayoutComponent 
    }, 
    { 
     path  : "**", 
     component: PageNotFoundComponent 
    } 
]; 
export const routing = RouterModule.forRoot(routes); 

私はPageNotFoundComponentを参照してくださいすべての時間。削除「**」ルータは、その後、私はエラーが表示された場合:

Error: Cannot match any routes: '' 

モジュール:

@NgModule({ 
       declarations: [ 
        MainComponent, 
        components 
       ], 
       imports  : [ 
        routing, 
        BrowserModule 
       ], 
       providers : [ 
        appRoutingProviders 
       ], 
       bootstrap : [MainComponent] 
      }) 
+0

ルートを登録する場所にコードを追加できますか? – Sefa

+0

@SefaÜmitOraydone – Illorian

答えて

2
const routes = [ 
    { 
     path  : "", 
     pathMatch: 'full'; <<<<==== added 
     component: AuthLayoutComponent 
    }, 
    { 
     path  : "**", 
     component: PageNotFoundComponent 
    } 
]; 
export const routing = RouterModule.forRoot(routes); 

pathMatch: 'full'がなければ、ルータがマッチし''後に空のパスと子経路を探索し続けます。

関連する問題