我目前拥有的是具有此模板的父组件:
<div class="fxcol full-height" [ngStyle]="style">
<ng-container *ngFor="let container of form.Containers; let i=index">
<ev-container class="ev-container " [container]="container" [parentForm]="parentForm" [params]="params"></ev-container>
</ng-container>
</div>
我想要实现的是每个包装有ev容器的容器,都由下一个div元素来实现,如下所示:
<div class="fxcol full-height">
<ev-container class="ev-container"></ev-container>
<div class="fxcol full-height">
<ev-container class="ev-container"></ev-container>
<div class="fxcol full-height">
<ev-container class="ev-container"></ev-container>
</div>
</div>
</div>
此问题是否存在已知的解决方法?
谢谢!
答案 0 :(得分:0)
我没有检查,但是应该可以
<ng-container
[ngTemplateOutlet]="tpl"
[ngTemplateOutletContext]="{ index: 0, list: form.Containers }">
</ng-container>
<ng-template #tpl let-index="index" let-list="list">
<div *ngIf="list && list[index]" class="fxcol full-height" [ngStyle]="style">
<ev-container class="ev-container"
[container]="form.Containers[index]"
[parentForm]="parentForm"
[params]="params">
</ev-container>
<ng-container
[ngTemplateOutlet]="tpl"
[ngTemplateOutletContext]="{ index: index + 1, list: list }">
</ng-container>
</div>
</ng-template>