2015-05-11 51 views
1

我怎麼能告訴角是角增加了我的CSS類時數爲更大然後14和較小然後20角納克級(參數2間)

我現在有這樣的事情。

ng-class="{ day_yellow: weatherList.temp.max >= 15, }"> 

回答

1

您可以使用簡單的& &條件:

ng-class="{ day_yellow: weatherList.temp.max >= 15 && weatherList.temp.max < 20 }"> 
+0

此作品完美的感謝! :) –

+0

不客氣;) –

1

這是最通用的解決方案:

ng-class="{true: 'day_yellow', false: 'some_other_class'}[weatherList.temp.max < 20 && weatherList.temp.max > 14] 

如果您只需要在條件爲真CSS類,你可以用這個:

ng-class="{'day_yellow': weatherList.temp.max < 20 && weatherList.temp.max > 14} 

另一種方式是將條件放到你的控制器,然後在HTML中只使用變量:

控制器

$scope.condition = weatherList.temp.max < 20 && weatherList.temp.max > 14; 

HTML

ng-class="{'day_yellow': condition}