【发布时间】:2016-01-29 00:15:11
【问题描述】:
我想在我的 ng-style 中结合两种样式,其中一种是条件样式。
ng-style="{'height':height + '%'}"
ng-style="hasScroll !== 0 && {'width': (tableWidth) + 'px'}"
如果条件为假,如何在不覆盖宽度的情况下将它们结合起来?
以下不好,因为如果条件为 falsefalse,它会覆盖“宽度”属性:
ng-style="{ 'height': height + '%', 'width': hasScroll !== 0 ? (tableWidth) + 'px' : undefined }"
【问题讨论】:
-
第二个 ng-style 中的 && 不是问号吗?