I just started learning router in angular and I am unable to use named outlet, please take a look at the following code
const routes: Routes = [{
path: "about",
component : AboutComponent,
children : [{
path : "contact",
component: ContactComponent }, {
path : "message",
component: MessageComponent }, {
path : "",
component: ContactComponent },
]},
{
path: "home",
component : HomeComponent
// outlet : "main" When I add this, it is not working
},{
path: "",
component : HomeComponent,
outlet : "main"
}];
app.component.html
------------------
<h1>The Header</h1>
<a routerLink="home">Home</a>
<a routerLink="about">About</a>
<router-outlet></router-outlet>
<router-outlet name="main"></router-outlet>
<h1>The footer</h1>
The above code works fine but when I add outlet to the path:'home'
, it says
Error: Cannot match any routes. URL Segment: 'home'
.