javascript - AngularJS ng 样式不起作用

标签 javascript angularjs

我正在尝试使用 AngularJS ng-stylediv 上应用背景色。我的颜色来自数据库。它不适合我。有谁能够帮助我。

<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>

最佳答案

http://plnkr.co/edit/LV96s0szWbBFkzCCKfpJ?p=preview

这更像是您需要的。看一看。

关于javascript - AngularJS ng 样式不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22013818/

相关文章:

javascript - 是否可以在 Safari 中打开由 window.webkitURL.createObjectURL 生成的 url?

javascript - 在 Three.js 中将 Material 设置为网格的固定部分

javascript - `ng-model` 属性在 Angularjs 验证中的意义是什么?

javascript - 如何使用 img 元素将数据与 angularJS 绑定(bind)

javascript - 如何在 html 文本中允许数字、退格、删除、左右箭头键?

javascript - Chrome.storage 无法正确存储数组

javascript - AngularJS按钮点击不触发功能

javascript - SweetAlert2 : Set dialog height

javascript - 如何检测JS中的焦点改变事件?

javascript - AngularJS ng-class,表单脏时的条件