Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set Angular 6 Material sidenav to open right to left from the right side of the screen

This is the code example being used in angular Material for Sidenav. Im using this very same example on my page. However, I could find any instructions how to open the sidenav from left to right from the right side of the screen. Anybody knows how to ?

<mat-sidenav-container class="example-container">
  <mat-sidenav #sidenav mode="side" [(opened)]="opened" (opened)="events.push('open!')"
               (closed)="events.push('close!')">
    Sidenav content
  </mat-sidenav>

  <mat-sidenav-content>
    <p><mat-checkbox [(ngModel)]="opened">sidenav.opened</mat-checkbox></p>
    <p><button mat-button (click)="sidenav.toggle()">sidenav.toggle()</button></p>
    <p>Events:</p>
    <div class="example-events">
      <div *ngFor="let e of events">{{e}}</div>
    </div>
  </mat-sidenav-content>
</mat-sidenav-container>
like image 751
Carl.G Avatar asked May 13 '18 02:05

Carl.G


People also ask

How to use sidenav in Angular Material?

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.

How to close sidenav Angular Material?

close() you get closing only if in over mode. Show activity on this post. Adding (click)="sidenav. close()" along with the routerLink="/whatever/path/here" works.


1 Answers

If you look to the API tab there is an input directive position for you to define.

position: 'start' | 'end'

The side that the drawer is attached to.

<mat-drawer-container class="example-container">
  <mat-drawer #sideNav mode="side" opened="true" position="end">
    Right drawer
  </mat-drawer>
  <mat-drawer-content>
    Main content
  </mat-drawer-content>
</mat-drawer-container>

DEMO

like image 178
Roel Avatar answered Oct 03 '22 11:10

Roel