切换上NG-点击CSS [英] Toggle css on ng-click
本文介绍了切换上NG-点击CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的code的基本思想是:
This is the basic idea of my code:
HTML(玉):
#preferencesBox(ng-click="toggleCustom()")
.glyphicon.glyphicon-heart
CSS:
#preferencesBox.active{
color: #d04f37;
}
角:
$scope.check = true;
$scope.toggleCustom = function() {
$scope.check = $scope.check === false ? true: false;
};
我想补充的CSS 颜色:#d04f37
当用户点击父#preferencesBox
。添加/删除。主动
是jQuery的方式。应该怎样我的纳克级
或休息code样子?
I want to add the css color : #d04f37
when the user clicks the parent #preferencesBox
. Adding/removing .active
is the jQuery way. How should my ng-class
or the rest code look like?
推荐答案
您可以使用纳克级
内的前pression将观看检查
变量:
You can use an expression inside ng-class
that will watch the check
variable:
ng-class="{'active' : check}"
在检查
= 真正
,添加类有效
这篇关于切换上NG-点击CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文