Reputation: 221
I have create routes on my module and import it as child.
in an 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);
IN app.routing.ts
I have this
const appRoutes: Routes = [
{ path: '', redirectTo: '/admin', pathMatch: 'full' },
{ path: 'login', component: AppLoginComponent }
];
export const AppRouting: ModuleWithProviders = RouterModule.forRoot(appRoutes);
now when its redirecting to the first homecomponent successfully. but when i try url localhost/admin/products.
its giving me an error
Cannot match any routes. URL Segment: 'admin/products'
Upvotes: 1
Views: 523
Reputation: 21
You need to remove AdminRO from the router outlet which you are using in the secondary module.
Upvotes: 2
Reputation: 872
Named outlets are the targets of secondary routes. If you want to navigate to secondary routes from browser, please enter the url as follows
http://.../admin(AdminRO:products)
The admin is the primary navigation. Parentheses surround the secondary route. The secondary route consists of an outlet name (AdminRO), a colon separator, and the secondary route path (products).
Upvotes: 0