I am trying to display multiple Mat-expansion-panel within a Mat-accordian by using *ngFor. I need to add a new mat-expansion-panel on click of a button which i am able to do. I am also required to expand (open) this newly added expansion panel on click of the button, and this is what i have been unable to achieve. Please help.
Stackblitz - https://stackblitz.com/edit/angular-fh5vu1-g6phe6?file=app%2Fexpansion-steps-example.ts
export class ExpansionStepsExample {
items: number[] = [1,2,3];
AddNewRow() {
this.items.push(4);
}
}
<mat-accordion class="example-headers-align">
<mat-expansion-panel *ngFor="let item of items;">
<mat-expansion-panel-header>
<mat-panel-title> {{item}} </mat-panel-title>
</mat-expansion-panel-header>
{{item}}
</mat-expansion-panel>
</mat-accordion>
<button (click)="AddNewRow()" value="Add New"> Add New </button>