Home > database >  How do I close MatSlidePanel
How do I close MatSlidePanel

Time:11-03

I have a side panel. I am trying to close the side panel on user action. However, I am getting below error on this action. Property 'close' does not exist on type 'MatSlidePanel'.ts(2339)

Here is the code I have tried: ts file

constructor(
    public slidePanel: MatSlidePanel,
   ) { }
  
  
  onClose(): void {
    this.slidePanel.close();
  }

CodePudding user response:

In the source code if ngx-mat-slide-panel (https://github.com/mandhu/angular-components/blob/master/projects/mat-slide-panel/src/lib/mat-slide-panel.ts) you can see that the function is called dismiss() and not close(). So you should probably use this function to close the side panel again.

Nevertheless it makes me wonder if you do not have stuff like autocompletion in place. Usually you should get hints on what functions or properties exist are available.

  • Related