import { Component , ViewChild } from '@angular/core' ; import { MatSidenav } from '@angular/material/sidenav' ; title @ Component ( { selector : 'sidenav-disable-close-example' , templateUrl : 'sidenav-disable-close-example.html' , styleUrls : [ 'sidenav-disable-close-example.css' ] , } ) export class SidenavDisableCloseExample { @ ViewChild ( 'sidenav' ) sidenav : MatSidenav ; reason = '' ; close ( reason ) { this . reason = reason ; this . sidenav . close ( ) ; } shouldRun = [ /(^|\.)plnkr\.co$/ , /(^|\.)stackblitz\.io$/ ] . some ( h => h . test ( window . location . host ) ) ; }