I am using AngularJS Material and I would like to apply md-colors=""
values based on an expression the same way an expression can be used with ng-class=""
. I have not been able to get this working.
我正在使用AngularJS材料,我想基于表达式应用md-colors =“”值,就像表达式可以与ng-class =“”一样使用。我无法让这个工作。
Here's an example :
这是一个例子:
<md-button md-colors="{background:'accent-900-0.43' : mode == 'development'}" ng-click="setMode('development')">
development
</md-button>
The desired output is that the md-button will take on the accent-900 background color if the condition mode=='development'
is true.
如果条件模式=='development'为真,则所需的输出是md按钮将采用重音-900背景颜色。
Can md-colors be used this way?
可以用这种方式使用md-colors吗?
1 个解决方案
#1
7
you can use ternary operation inside md-color
to assign styles
你可以在md-color中使用三元运算来分配样式
<md-button md-colors="mode == 'development' ? {background:'accent-900-0.43'} : {background:'whatever_condition_false_color'} " ng-click="setMode('development')">
development
</md-button>
#1
7
you can use ternary operation inside md-color
to assign styles
你可以在md-color中使用三元运算来分配样式
<md-button md-colors="mode == 'development' ? {background:'accent-900-0.43'} : {background:'whatever_condition_false_color'} " ng-click="setMode('development')">
development
</md-button>