1

I have an app.component.html file with a <router-outlet></router-outlet>. This obviously means that all the rest of my components use the app.component.html as their base html container.

However I want a login page (and possibly a couple of other pages) that will need a different html layout.

How do I do this?

Poul Kruijt
  • 69,713
  • 12
  • 145
  • 149
coolblue2000
  • 3,796
  • 10
  • 41
  • 62

1 Answers1

1

If you declare the the login page component and those couple of pages under the main app component route, by adding them in the children array then only, they would have the base base url as that of your app component.

You can add the other entry in the routes array for the login components that do not have the app component as their parent.

for example:

const appRoutes: Routes = [

//Site routes goes here 
{ 
    path: '', 
    component: MainComponent,
    children: [
      { path: '', component: HomeComponent, pathMatch: 'full'},
      { path: 'about', component: AboutComponent }
    ]
},
 { path: 'login', component: LoginComponent}
]
Minal Shah
  • 1,402
  • 1
  • 5
  • 13