Search code examples
angularangular-materialangular-flex-layout

where is this toggle() function coming from in angular code?


I'm using this code for a side nav: https://stackblitz.com/edit/mat-sidenav-responsive?file=app%2Fsidenav-responsive-example.html

its uses this from template reference variable #sidenav

<a href="#" (click)="sidenav.toggle()">Vodafone Airtime</a>

I want to know where is this .toggle() function coming from, its a property of the sidenav object? where can I view all these properties?


Solution

  • Yes, it's a method of Angular Material's sidenav. This component is assigned to a variable named sidenav here:

      <mat-sidenav #sidenav [(mode)]="over" [(opened)]="opened" class="bottom-to-top">
    

    For further reading on sidenav's methods, inputs, outputs and properties, best start with the official docs: https://material.angular.io/components/sidenav/api