Home > Software design >  How to hide mat-expansion-panel in Angular?
How to hide mat-expansion-panel in Angular?

Time:10-22

enter image description here

I want to hide it when array is empty

CodePudding user response:

You can do this declaratively by setting the value of input expanded to false if some condition is met, or imperatively by calling method toggle on your MatExpansionPanel ViewChild from your component. See angular-material docs.

<mat-expansion-panel [expanded]="isExpanded ? true : false">
  <other stuff/>
</mat-expansion-panel>

CodePudding user response:

You can use [hidden]="clause" like this:

  <mat-expansion-panel [hidden]="true">
     ...
  </mat-expansion-panel>
  • Related