1
<div ng-if="item.attribute == 'attribute1'">
    doSomething
</div>

<button class="button button-block button-postive waves-effect waves-button waves-light">
    Button 1
</button>

item.attribute == attribute1の場合、ボタンの色がサンゴになるようにしたい

.button.button-block, .button.button-full {

    background-color: coral;
    color: #fff;
}

これは可能ですか?ありがとうございました

4

3 に答える 3

2

ngクラスを使用

ng-class="{ 'style': condition, 'style2' : condition2}"

具体的には:

ng-class="{ 'button-block': item.attribute == 'attribute1'}"

https://docs.angularjs.org/api/ng/directive/ngClass

于 2015-08-11T15:29:39.900 に答える
0

これを実現するために使用できますng-class

<button ng-class="{'button-block': item.attribute==attribute1}">
于 2015-08-11T15:32:33.957 に答える
0

クラスを宣言せずにそれを行う別の方法を次に示します。

ng-style="item.attribute == 'attribute1' 
    && {'background-color':'red', 'color':'white'} || {'background-color':'blue', 'color':'white'}"
于 2016-04-03T18:25:00.493 に答える