1

I need to display a list of objects of different types in a repeating list of MaterialExpansionPanels. When the user clicks on each panel to expand it, the contents depend on the type of object.

I don't really have any idea for how to proceed - would the deferredContent directive allow me to determine which component to display at runtime when the panel is expanded? How would I specify the contents of the panel from my component code?

An example of something similar would be helpful!

mjeffw
  • 113
  • 10
  • 1
    `deferred` won't help at all. You can do something like explained in https://stackoverflow.com/questions/36325212/angular-2-dynamic-tabs-with-user-click-chosen-components/36325468#36325468. The beta.17 example should be pretty much the same in Dart. – Günter Zöchbauer Jun 16 '17 at 05:57

1 Answers1

0

There is nothing really specific to material expansion here, you need to the the same things you would do in any place where *ngFor is used. You have basically two options:

  1. Use series of *ngIf / *ngSwitch and render whatever you need inside
  2. Use Dynamic Component. This usually requires creating some model class with types and DI bindings to pass parameters.
rkj
  • 8,787
  • 2
  • 29
  • 35