*ngFor循环体上使用*ngIf?

版权声明:本文为博主原创文章,转载请注明出处!有时候也不是原创,手快就选了(我的文章随意转载复制,不在乎的哈!) https://blog.csdn.net/qq_31384551/article/details/82179737

代码如下(错误的使用

<div class="item-list" *ngFor="let item of communityList" *ngIf="item!=null">{{item.name}}</div>

正确使用方式:使用ng-container嵌套,不影响布局

<ng-container *ngFor="let item of communityList">
    <div class="item-list"  *ngIf="item!=null">{{item.name}}</div>
  </ng-container>

猜你喜欢

转载自blog.csdn.net/qq_31384551/article/details/82179737
今日推荐