Angular 2 找不到默认路由器
Angular 2 can't find default router
我有一个简单的路由器:
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]
})
const routes = [
{
path : "",
pathMatch: 'full'; <<<<==== added
component: AuthLayoutComponent
},
{
path : "**",
component: PageNotFoundComponent
}
];
export const routing = RouterModule.forRoot(routes);
没有pathMatch: 'full'
路由器在''
匹配后继续搜索具有空路径的子路由。
我有一个简单的路由器:
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]
})
const routes = [
{
path : "",
pathMatch: 'full'; <<<<==== added
component: AuthLayoutComponent
},
{
path : "**",
component: PageNotFoundComponent
}
];
export const routing = RouterModule.forRoot(routes);
没有pathMatch: 'full'
路由器在''
匹配后继续搜索具有空路径的子路由。