唔,jQuery的点击改变class样式用angular该怎么写?

$(function(){
    $(".sem").click(function(){
        $(".comments").hide();
        $(this).parent().next(".comments").show();
        $(".circle.active").removeClass("active");
        $(this).parent().addClass("active");
    });
});


这是jQuery的代码,我想改用angular的话,这个要怎么写呀?
阅读 3.2k
2 个回答

在你要加样式的元素上加 ng-class="{'active':classShowed}",classShowed是控制样式是否显示的变量。在controller中有$scope.classShowed bool型变量与之对应。在点击事件中控制$scope.classShowed的值(true,false)就能显示和隐藏样式了。详细自己百度 angular ng-class。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题