mat-expansion-panel not support *ngFor in mat-accordion
See original GitHub issueBug, feature request, or proposal:
without *ngFor
, 2 expansion-panel
will work correctly inside a mat-accordion
.
<mat-accordion>
<mat-expansion-panel>
<mat-expansion-panel-header>
This is the expansion 1 title
</mat-expansion-panel-header>
This the expansion 1 content
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
This is the expansion 2 title
</mat-expansion-panel-header>
This the expansion 2 content
</mat-expansion-panel>
</mat-accordion>
But if I use *ngFor
, the content
will not open when I click.
<mat-accordion>
<mat-expansion-panel *ngFor="let panel of panels">
<mat-expansion-panel-header>
{{panel.title}}
</mat-expansion-panel-header>
{{panel.content}}
</mat-expansion-panel>
</mat-accordion>
What is the expected behavior?
with *ngFor
, it should still work as expected.
What is the current behavior?
with *ngFor
, the expansion panel will not open.
What are the steps to reproduce?
Providing a StackBlitz/Plunker (or similar) is the best way to get the team to see your issue.
Plunker starter (using on @master
): https://goo.gl/DlHd6U
StackBlitz starter (using latest npm
release): https://goo.gl/wwnhMV
The plunker template not working…
What is the use-case or motivation for changing an existing behavior?
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 5.0.0-beta7 material 2.0.0-beta.12 Typescript 2.4.2 Browsers Chrome
Is there anything else we should know?
Thanks.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:5 (1 by maintainers)
Top Results From Across the Web
mat-expansion-panel body won't work with ngFor
The array has no fixed length, so I try to add content to the body with *ngFor. But the body stays empty. I...
Read more >Dynamic Expansion Panel - StackBlitz
Starter project for Angular apps that exports to the Angular CLI.
Read more >Using Structural Directives in Mean Stack - javatpoint
2) Now, we will use a special directive, i.e., *ngFor, and it is essentially a helper ... <mat-accordion>; <mat-expansion-panel *ngFor = "let post...
Read more >54 - Angular Material: Panel - mat-expansion-panel
Tiene la posibilidad que al encerrarlo entre las etiquetas mat-accordion cuando se abre el contenido de un 'mat-expansion-panel' se cierra si hay ...
Read more >Tech: How I Fix Strange Behavior of MatExpansionPanel
Since the data structure has changed MatExpansionPanel suddenly ... To mitigate this problem, *ngFor also supports an option to track down ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@julianobrasil , thank you very much, I use
sideNav
and it seems I used wrongcss
, it worked now.https://stackblitz.com/edit/expansion-panel-axzbag?file=styles.scss
Your code is working right: https://stackblitz.com/edit/expansion-panel
Try to modify the code in stackblitz to reproduce the problem.