javascript - Angular ng-class 和 bootstraps css

标签 javascript css angularjs twitter-bootstrap

我正在使用 bootstrap 中的“table-striped”和 angularjs 中的“ng-class”来呈现表格。这个想法是显示条纹表格,当点击一行时,它会突出显示。

以下内容是由于在奇数行上“点击”而从 chrome 复制的。

<div class="table-responsive" id="Destination">
    <table class="table table-striped" id="destinationTable">
    <thead>
...
    </thead>
    <tbody>
        <!-- ngRepeat: entity in destinations -->
        <tr ng-repeat="entity in destinations" ng-click="setName()" ng-class="{'highlight' : destinationName == entity.name}" class="ng-scope highlight">

    </tbody>
    </table>
</div>

如你所见,"class="ng-scope highlight"已经由angularjs在那一行生成了,只是没有生效。

同样的代码对偶数行也能很好地工作,这对我来说也很奇怪。我没有看到奇数行点击和偶数行点击之间的 html 差异。

在“bootstrap.css”中,它有,

.table-striped > tbody > tr:nth-of-type(odd) {background-color: #f9f9f9;}

我想知道这个类是否用于覆盖我想要的“亮点”。

有什么办法可以解决吗?

最佳答案

我遇到了同样的问题,它似乎与表格 strip 化中的 css 有关。

解决方法是执行以下操作:

  1. 要么使用 ng-style 指令

  2. 在要显示的类属性的 css 中使用 !important(例如 background-color: #dff0d8 !important; 用于突出显示类)

    第 1 项可能是进入此处的更好方法,但两者都应该有效。

关于javascript - Angular ng-class 和 bootstraps css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33395839/

相关文章:

javascript - 防止删除分配给文档就绪的处理程序

html - 使嵌套的 div 在页面调整大小时可滚动

javascript - 打开嵌入在 div 中的 pdf

javascript - HTML5 canvas 正在调整我的图片大小

javascript - 如何在客户端执行服务器返回的javascript

html - 如何删除 Bootstrap3 容器的背景?

css - 如何使用angularJS更改IONIC中单选按钮子项的样式

javascript - 监视 $rootScope 结果 $scope 也被监视

javascript - 在 ui-bootstrap typeahead 中使用有意义的键处理对象

javascript - 为什么在触发 window.location.reload 时清除其余功能代码?