Angular2 ngClass不起作用

时间:2017-09-15 08:52:58

标签: html css angular

我想添加一个带有条件的类,但它不起作用

    <tr *ngFor="let time of times; let i = index">
        <td [ngClass]="{'red-time':checkInvalid(time['Proles Arrive'])}">{{time['Proles Arrive']}}</td>
</tr>

这是我的HTML

  checkInvalid(entry: string){ 
console.log("This is the entry:"  + entry);
    return entry === 'Invalid Entry';
  }

但是这个课程从未被添加,即使我记录了它所说的条目&#34; Invalid Entry&#34;

即使我使用&#34; [ngClass] =&#34; {&#39; red-time&#39;:true}&#34;它还没有添加课程。

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

更改条件如下

<td [ngClass]="{'red-time':checkInvalid(time['Proles Arrive'])==true}">{{time['Proles Arrive']}}</td>
相关问题