如何使用angularjs addClass方法 [英] How to use addClass method in angularjs
本文介绍了如何使用angularjs addClass方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须限制在类中angularjs指令。我如何可以通过使用angularjs addClass方法添加此
I have an angularjs directive restricted to class. How can I add this by using addClass method in angularjs
指令
app.directive('number', function() {
return {
restrict: 'C',
link: function () {
}
};
});
code
<div id="test"></div>
我知道这是可能通过使用jQuery像下面这样。
I know it is possible by using jQuery like the following.
$( "#test" ).addClass( "number" );
请帮我用angularjs做
Please help me in doing it by using angularjs
推荐答案
您不需要使用.addClass()角提供纳克级的指令,有条件地添加类。
You don't need to use .addClass() angular provide ng-class directive to add class conditionally.
ng-class="{number:[condition]}"
这将增加班号,只要您的病情返回true
it will add class number whenever your condition return true
是的,但你的指令将不会受到此使用我pviously误解了你的问题$ P $。
yes but your directive will not be used by this I misunderstood your question previously.
这篇关于如何使用angularjs addClass方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文