2015-05-11 25 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}