我正在尝试使用调用的指令ng-class从 CSS 文件中设置乘法规则。这是代码的一部分
<div class="filterToggleBtn thumbnail"
ng-class="{ filterToggleBtnSide notificationColor:notificationState }">
</div>
变量filterToggleBtnSide和notificationColor包含 CSS 规则名称的字符串。
变量notificationState集true或false.
问题的关键是-我如何始终使用filterToggleBtnSiderule ,notificationColor只有这样notificationState才是真的。
我试图在下面制作类似的代码
<div class="filterToggleBtn thumbnail"
ng-class="{ filterToggleBtnSide && notificationColor:notificationState }">
</div>
<div class="filterToggleBtn thumbnail"
ng-class="{ filterToggleBtnSide, notificationColor:notificationState }">
</div>
<div class="filterToggleBtn thumbnail"
ng-class="{ filterToggleBtnSide:true, notificationColor:notificationState }">
</div>
在最后一个示例中,只有第二个表达式有效。如果有人帮助,我将不胜感激;D 谢谢