Вручную вставить компонент материала в элемент HTML

Как добавить внутрь DivElement список компонентов материала, скажем MaterialCheckboxComponent?

DivElement.children это List<Element>и я не вижу, как разыграть List<MaterialCheckboxComponent> в List<Element>,

Как я могу добиться того, что сделано с MaterialCheckboxComponent вручную?

1 ответ

Решение

https://webdev.dartlang.org/angular/note/faq/component-loading - раздел о динамическом добавлении компонентов

@Component(
  selector: 'ad-view',
  template: r'''
    This component is sponsored by:
    <template #currentAd></template>
  ''',
)
class AdViewComponent {
  final ComponentLoader _loader;

  AdViewComponent(this._loader);

  @ViewChild('currentAd', read: ViewContainerRef)
  ViewContainerRef currentAd;

  @Input()
  set component(ComponentFactory component) {
    _loader.loadNextToLocation(component, currentAd);
  }
}
Другие вопросы по тегам