3
我想使用AngularJS ng-style
在div
上應用背景色。我的顏色來自數據庫。它不適合我。有誰能夠幫助我。AngularJS ng樣式不起作用
<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>
是colorpicker你寫的指令嗎? –
你可以創建一個小提琴嗎? – doodeec
btw。在div元素上定義'ng-model'有什麼用?我現在已經看過幾次了,但是我不太明白它應該做什麼。 – doodeec