[Fixed] Router-Outlet Navigation With Constant Sidebar and NavBar on Angular


I’m a bit confused on what to do on how to place my router-outlet. I have tried researching for similar cases but to no avail.
Here is the scenario
I have a dashboard component which loads after a login is successful. The dashboard contains a sidebar, footer and navigation component declared on the html. Now, when I click on a user link to show me the list of users, it loads the user component but the sidebar, footer and navigation disappears and I am left with only the user component. I just want a situation when I click on a link in the sidebar, it just changes the content without removing the sidebar, footer and nav……
PS: the user component has its own module, then I imported this into the appModule as usual.

Here is what I have so far.






            <a id="formsli" (click)="anchorClicked($event)"
              ><i class="fa fa-user"></i> User<span class="fa fa-chevron-down"></span
            <ul class="nav child_menu">          
              <li><a [routerLink]="['/user/list']">User List</a></li>
              <li><a [routerLink]="['/user/new']">New User</a></li>


const routes: Routes = [
    { path: 'user/list', component: UsersComponent },
    { path: 'user/new', component: UserComponent },


export const AppRoutes2: Routes = [
  { path: '', component: LoginComponent},
  { path: 'content', component: ContentComponent },
  { path: 'dashboard', component: DashboardComponent },

imports: [
      RouterModule.forRoot(AppRoutes2, {useHash: false}),

If i click on the user list link, the sidebar, nav and footer disappears. I want it to remain and just change the content area.

Please, what am i doing wrong or not doing right??



     //use the ngIf directive to either create or destroy the div with       static content (this is determined from the app.component.ta
      <div class='user-nav' *ngIf="isLoggedIn">
     //anything that is routed will show up here
    //if you want the footer to only be available after logging in add it here too

Leave a Reply

(*) Required, Your email will not be published