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
Asked
Active
Viewed 657 times
2 Answers
2
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();)}

Munzer
- 2,216
- 2
- 18
- 25
1
Get all expansion panel instance using ViewChildren decorator
@ViewChildren(MatExpansionPanel) expansionPanel: QueryList<MatExpansionPanel>;
Then call open method on it when you click openAll button
openll() {
this.expansionPanel.toArray().forEach((panel)=>{
panel.open();
})
}

Chellappan வ
- 23,645
- 3
- 29
- 60