如何在angularjs中将ng-class添加到指令中 [英] How to add ng-class to the directive in angularjs
本文介绍了如何在angularjs中将ng-class添加到指令中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望在使用指令调用函数的真实条件下激活类,如下所示使用指令
@ *
我尝试过:
AlladinApp.directive('customLabel',customLabel) ;
函数customLabel(){
var directive = {
link:link,
restrict:'EA',
templateUrl:'/ app /customlabel_tmpl.html',
范围:{
listtype: '=',
onselection:'&',
onselect:'&',
listitems:'='
}
};
返回指令;
函数链接(范围,元素,阁下){}
}
以下是模板
以下是我在视野中所取代的内容的页面< li>
商品
< custom-label listitems =SearchOptions.stylelisttype =Style>
在这里,onselection正在获得预期的结果但是onselect无法正常工作(ng-class不工作)请帮助我。谢谢提前
解决方案
https://docs.angularjs.org/api / ng / directive / ngClass [ ^
i want to active class on true condition of some call to a function as follows using directives
@*
What I have tried:
AlladinApp.directive('customLabel', customLabel);
function customLabel() {
var directive = {
link: link,
restrict: 'EA',
templateUrl: '/app/customlabel_tmpl.html',
scope: {
listtype: '=',
onselection: '&',
onselect: '&',
listitems:'='
}
};
return directive;
function link(scope, element, attrs) { }
}
folowing is the template
following is what i have replaced in view page for< li>
items
<custom-label listitems="SearchOptions.style" listtype="Style">
Here,onselection is getting the expected result but onselect is not working (ng-class is not working)plase help me.Thanks in advance
解决方案
https://docs.angularjs.org/api/ng/directive/ngClass[^]
这篇关于如何在angularjs中将ng-class添加到指令中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文