angular2的ngfor ngif指令嵌套

时间:2022-11-27 23:02:03

ng2 结构指令不能直接嵌套使用,可使用<ng-container>标签来包裹指令

示例如下:

<ul>
<ng-container *ngFor="let item of lists">
<div class="thumb p-date" *ngIf="item.picurl">
<a href="# "><img src="{{item.picurl}} " alt=" " style="width:79px;height: 70px; "></a>
</div>
</ng-container>
</ul>