我在我的模块上创建了路由并将其作为子模块导入。
在一个 module.Routing.ts
export const routes: Routes = [
{
path : 'admin',
component : IndexComponent,
children :[
{ path: '', component: HomeComponent, outlet:'AdminRO' },
{ path: 'products', component: ProductsComponent, outlet: 'AdminRO' }
]
}
];
export const routing: ModuleWithProviders = RouterModule.forChild(routes);
在 app.routing.ts
我有这个
const appRoutes: Routes = [
{ path: '', redirectTo: '/admin', pathMatch: 'full' },
{ path: 'login', component: AppLoginComponent }
];
export const AppRouting: ModuleWithProviders = RouterModule.forRoot(appRoutes);
现在当它成功重定向到第一个 homecomponent 时。但是当我尝试使用 url localhost/admin/products.
它给了我一个错误
Cannot match any routes. URL Segment: 'admin/products'