angular2中*ngFor同时适用*ngIf

在一个*ngFor中,如果同时使用了*ngIf将导致转化为template出错,那么*ngFor中我们如果也想条件性渲染部分跳过呢?放弃语法糖可以做到

<p *ngFor="let hero of heroes">{{hero.name}}<p>

/*====================*/

//只显示cmx除外的英雄
<template ngFor let-hero [ngForOf]="heroes">
    <p *ngIf="hero.name !== 'cmx'">{{hero.name}}</p>
</template>

 

posted on 2017-08-01 14:55  XIE7654  阅读(1031)  评论(0编辑  收藏  举报