我正在尝试使用AngularJS div
在ng-style
上应用背景颜色。我的颜色来自数据库。它不适合我。有谁能够帮我。
<div ng-controller="IndexCtrl">
<div style="width: 500px;">
<table class="table table-striped table-bordered table-condensed table-hover">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Edit</th>
</tr>
</thead>
<tbody ng-repeat="color in colors">
<tr ng-show="edit">
<td><input type="text" ng-model="color.ID" ng-change="color.changed=true" /></td>
<td>
<input type="text" ng-model="color.Name" colorpicker ng-change="color.changed=true" />
</td>
<td><input type="button" class="btn btn-primary" value="Save" ng-click="edit=false; save();" /> </td>
</tr>
<tr ng-hide="edit">
<td><strong>{{color.ID}}</strong> </td>
<td><div style="width:20px; height:20px; border:thin solid black" ng-model="color.Name" ng-style="{'background-color' : color.Name}"></div> </td>
<td><input type="button" class="btn btn-primary" value="Edit" ng-click="edit=true;" /></td>
</tr>
</tbody>
</table>
</div>
</div>