routing in angular 5 : load component in part of page


i have one component for sidebar , when user click on one of options load component in part of page .

but when i click on options load new component in all of page .

how can i solve this problem ?

<ul nz-menu [nzMode]="'inline'" style="width: 240px;" [nzTheme]="theme?'dark':'dark'">
  <li nz-submenu nzOpen>
    <span title><i class="anticon anticon-mail"></i>  Letter </span>
      <li nz-menu-group>
          <li nz-menu-item><a [routerLink]="['/Inbox']">Inbox &nbsp;&nbsp;<nz-badge [nzCount]="555"></nz-badge>
          <li nz-menu-item><a [routerLink]="['/Drafts']">Drafts</a></li>
          <li nz-menu-item><a [routerLink]="['/NewLetter']">Write Letter</a></li>
          <li nz-menu-item><a [routerLink]="['/ListLetter']">List Letter</a></li>
<div class="container">


    const routes: Routes = [
  {path: 'Inbox', component: InboxComponent},
  {path: 'Profile', component: ProfileComponent},
  {path: 'NewLetter', component: CreateLetterComponent},
  {path: 'Drafts', component: DraftsComponent},
  {path: 'ListLetter', component: ListLetterComponent},
  {path: '', redirectTo: 'Inbox' +
    '', pathMatch: 'full'}

Image : I need load component in part of page


Look at the offical tutorial. I think you want to have a <nav> tag where you specify the sidebar.

Also – is that the app.component.html you linked? Are you sure, you did not specify more <router-outlet>s by chance?

Answered By – ForestG

Answer Checked By – Terry (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.