Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我必须在语法上遗漏一些东西,但是如果未填充范围变量,我怎么能有默认的背景颜色呢?
以下对我不起作用:
ng-style="{('backgroundColor':button.color || '#FF6600')}"
但是,此语法适用于其他地方:
<p>{{button.label || 'Some Text'}}<p>
我在使用 ng 风格的语法时做错了什么?
只需删除额外的括号,它就会起作用:
ng-style="{'backgroundColor':button.color || '#FF6600'}"