我有一个网格组件。我希望它接受可变数量的项目并连续显示。像这样:
grid.component.html
<ng-content fxLayout="row" fxLayoutGap="12px">
for ng-item-in-component -> item:
<item fxFlex="1"></item>
</ng-content>
在不知道传入的项目是什么的情况下该怎么做?
一个示例用法是:
<app-grid>
<app-hero-detail></app-hero-detail>
<app-hero-detail></app-hero-detail>
<app-hero-detail></app-hero-detail>
<app-hero-detail></app-hero-detail>
</app-grid>
这将导致:
<app-grid fxLayout="row" fxLayoutGap="12px">
<app-hero-detail fxFlex="1"></app-hero-detail>
<app-hero-detail fxFlex="1"></app-hero-detail>
<app-hero-detail fxFlex="1"></app-hero-detail>
<app-hero-detail fxFlex="1"></app-hero-detail>
</app-grid>