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>
原文地址:https://www.cnblogs.com/XIE7654/p/7268568.html