2016-10-12 1 views
1

을 찾을 수 없습니다 :각도이 내가 간단한 라우터가 기본 라우터

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ÜmitOray 완료 – Illorian

답변

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

pathMatch: 'full'없이 라우터가 일치 '' 후 빈 경로와 하위 경로 검색을 계속합니다.