在Angular Js中切换

时间:2014-11-18 09:16:32

标签: jquery angularjs toggle

我在Jquery中完成了一个片段。我需要在角度Js

中实现它
$('.halfonoff').click(function(){  

 $('.halfonoff').removeClass('active');

 $(this).addClass('active')

})

以下是示例http://jsfiddle.net/uws2g48g/

以下是angularJs http://jsfiddle.net/uws2g48g/2/

中的代码

1 个答案:

答案 0 :(得分:0)

检查http://jsfiddle.net/qe7vex2L/

.active > div:first-child,
.onoff:not(.active) > div+div
{
    background-color: #f05a43;
    color: white;   
}

对于jQuery,你应该知道一个toggleClass函数。关于AngularJS,逻辑可能不同。