在经历了很多问题之后,我决定问这个......角度 [ngClass] 在 10 、 24 、 100 的值上工作很奇怪。我不知道背后的原因。希望大家可以帮忙...
<div class="clearfix table-responsive mt-5">
<table id="data_upload1" class=" table table-bordered table-striped table-hover selectParent">
<thead>
<tr>
<th class="pointer">Obs</th>
<th class="pointer">Date</th>
<th class="pointer">Price</th>
<th class="pointer">% Change</th>
</tr>
</thead>
<tbody>
<ng-container *ngFor="let price of priceList">
<tr>
<td >{{price.serial}}</td>
<td >{{price.period}} </td>
<td ><input autofocus (blur)="updateValue($event, price.price)" type="text"
[value]="value" [(ngModel)] = "price.price" placeholder = "" /></td>
<td [ngClass]="price.change >= price.hold ? 'red': 'greenn'">{{price.change}} </td>
</tr>
</ng-container>
</tbody>
</table>
</div>
<button type="button" id="add_user_submit" class="btn btn-blue1 center-block">Save</button>
</div>
</div>
这是来自后端的 JSON 格式
0:{id: 101, price: 40, period: "2018-02-01", hold: "10", change: "n.a."}
1:{id: 102, price: 42, period: "2018-03-01", hold: "10", change: "5.00"}
2:{id: 103, price: 43, period: "2018-04-01", hold: "10", change: "2.38"}
length:3
ngClass 在 10、100、24 等值上选择了错误的类,而不是 greenn,它以红色显示背景。