我想更改文本的颜色,如果 Pending 它应该绑定 class text-success 并且如果 On Time 它应该绑定 class text-danger,但是它不起作用..
<tr ng-repeat="entries in abc" ng-click="/#/mypage/{{entries._id}}">
<td>{{$index}} </td>
<td>{{entries.objective}}</td>
<td>{{entries.key_results[0].result}}</td>
<td ng-class="{text-success: entries.key_results[0].status == 'Pending', text-danger: entries.key_results[0].status == 'On Time' }">
{{entries.key_results[0].status}}
</td>
<td>{{entries.final_score}}</td>
<td>{{entries.owner_ids[0]}}</td>
<td> <a class="btn btn-sm btn-success"> View OKR </a></td>
</tr>
其他数据正在完美显示..控制器:
$scope.abc = [
{
"_id": "560b84bc1bf86c4334dd7233",
"objective": "My obj",
....
"key_results": [{
"result": "res1",
"current_score":0.6,
"final_score":0.7,
"status":"Pending"
},
{
"result": "res2",
"current_score":0.6,
"final_score":0.7,
"status":"Pending"
}]
},
{
"_id": "560b84bc1bf86c4334dd7233",
"objective": "My obj 2",
....
"key_results": [{
"result": "res1",
"current_score":0.6,
"final_score":0.7,
"status":"On time",
"_id": "560bb0a70aea6b067d961653"
},
{
"result": "res2",
"current_score":0.6,
"final_score":0.7,
"status":"On time",
"_id": "560bb0a70aea6b067d961652"
}]
}
]
我参考了:http: //jsfiddle.net/TheSharpieOne/NHS73/