I am trying to create "right navbar" with angular material 2 md-sidenav
. No matter what I do, it is always coming on the left. How can I change this to right sidenav instead?
<md-sidenav #sidenavright mode="side" class="app-sidenav" opened="true">
<app-question-rightnav></app-question-rightnav>
</md-sidenav>
Specifying the main and side contentBoth the main and side content should be placed inside of the <mat-sidenav-container> , content that you don't want to be affected by the sidenav, such as a header or footer, can be placed outside of the container. The side content should be wrapped in a <mat-sidenav> element.
Our main idea to hide SideNav is by creating multiple layouts. In the following routing configuration, we have 2 parent routes configured as login and home. With login we have simply LoginComponent which will be rendered in <router-outlet> and post login main route will be rendered.
Okay, it's easier than I thought, silly me!!
To align md-sidenav to right side, just add align="end"
to md-sidenav
element.
<md-sidenav align="end" #sidenavright mode="side" class="app-sidenav" opened="true">
<app-question-rightnav></app-question-rightnav>
</md-sidenav>
It's changed to position="end"
in the later versions
Example
<mat-sidenav #sidenavright position="end">
Right sideNav
</mat-sidenav>
<mat-sidenav-container>
<mat-sidenav #right position="start">
Start Sidenav.
</mat-sidenav>
<mat-sidenav #left position="end">
End Sidenav.
</mat-sidenav>
<div>
<button mat-button (click)="right.open()">right</button>
<button mat-button (click)="left.open()">left</button>
</div>
</mat-sidenav-container>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With