博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

angular2的ngfor ngif指令嵌套

Posted on 2017-03-30 21:47  徐自勉  阅读(539)  评论(0编辑  收藏  举报

angular2的ngfor ngif指令嵌套

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>