angularmultidimensional-arraymat-expansion-panel

How to expand all mat-expansion-panel with complex array by click a button?


I am trying to display Mat-expansion-panel by click "open all" button. Now, i face the problem is inner panel is not working. It only can open the outside only. I would like to open all panel with inner panel. How to achieve it ? Please help. stackblitz link


Solution

  • You are trying to expand expansion panels, but you are selecting accordion, this is the problem with your code, what you can do is use viewchildren , select all expansion panels, and then open them when you want. here is how the code will look like

      @ViewChildren(MatExpansionPanel) panels: QueryList<MatExpansionPanel>;
    
    
    openAll(){
    this.panels.forEach(panel => panel.open();)}