[英]Angular2 - ng-class not applying css
I'm just trying to implement a condition row formatting in a table but it is not working. 我只是想在表中实现条件行格式,但它不起作用。
The code is very simple: 代码很简单:
<style type="text/css">
.red {
color: red;
}
.blue {
color: blue;
}
</style>
<tr *ngFor="let c of customers" [class.selected]="c === selectedItem" ng-class="{1==1 ? 'red': 'blue'}">
The condition 1==1
is always true
, and should render the red class, but it doesn't apply either red or blue class. 条件
1==1
始终为true
,并且应呈现红色类,但不适用于红色或蓝色类。
I created this example. 我创建了这个例子。
<div>
<h2 [ngClass]="1==1?'red':'blue'">Hello {{name}}</h2>
</div>
html组件
<tr *ngFor="let c of customers" [class.selected]="c === selectedItem" [ngClass]="{1==1 ? 'red': 'blue'}">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.