question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mat-expansion-panel not support *ngFor in mat-accordion

See original GitHub issue

Bug, 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:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
JiaLiPassioncommented, Oct 13, 2017

@julianobrasil , thank you very much, I use sideNav and it seems I used wrong css, it worked now.

https://stackblitz.com/edit/expansion-panel-axzbag?file=styles.scss

1reaction
julianobrasilcommented, Oct 13, 2017

Your code is working right: https://stackblitz.com/edit/expansion-panel

Try to modify the code in stackblitz to reproduce the problem.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found