【发布时间】:2015-03-30 15:35:23
【问题描述】:
我想应用基于 JSON 响应的 css 类,例如,如果响应为“低”,我想要背景颜色为绿色并应用单选低 css 类,如果响应为“中等”,我想将背景颜色设为黄色。我如何可以使用 AngularJS 完成这项任务。
HTML
<form kendo-validator="ratingValidator" name="processRatingForm" novalidate ng-cloak
ng-controller="EditProcessRatingCtrl" class="border-box-sizing grids-fonts">
<p class="status">{{PrcsratingValidationMsg}}</p>
<div class="row">
<div class="form-group col-md-6">
<div>
<label class="control-label" for="processInherentRisk">Process
Inherent risk rating</label>
</div>
<div id="processInhRisk"
ng-model-options="{ updateOn: 'blur' }" ng-model="processRating.inherentRiskRatingKey" class="radio-low" >{{processRating.inherentRiskRatingKey}}</div>
</div>
<div class="form-group col-md-6">
<div>
<label class="control-label" for="finalOutcomeInherentRiskRatingKey">Process
Inherent risk Business Final</label>
</div>
<div id="irrFinalOutcome"
ng-model-options="{ updateOn: 'blur' }"
ng-model="processRating.finalOutcomeInherentRiskRatingKey" class="radio-medium">{{processRating.finalOutcomeInherentRiskRatingKey}}</div>
</div>
</div
</form>
【问题讨论】:
-
看看ngClass。
-
你的标题没有很好地计算问题..你应该考虑改变它
-
juz 将从 json 获得的值传递给 ng-class。分配 css 颜色值。
标签: javascript css json angularjs