我必须在角js中使用acitree jquery插件(来源:http://acoderinsights.ro/source/aciTree/aciTree-radio.html),以便列出我的所有树。
帮助我如何在angularjs指令中使用jquery插件.提前谢谢!!
发布于 2016-09-30 07:07:39
经过很长一段时间的尝试,我得到了一个解决方案,它似乎可以工作fine.After,包括必要的acitree包含文件,这里我已经编写了指令,在角js中包含acitree。
.directive('aciTree', function($compile) {
return {
restrict: 'A',
scope: {
content: '='
},
link: function (scope, element) {
scope.$watch('content', function () {
scope.checkTreeEvent = function(event, api, item, eventName, options) {
var id = api.getId(item);
switch (eventName) {
case 'checked':
break;
case 'unchecked':
break;
}
}
if (scope.content) {
element.aciTree(scope.content).bind('acitree', scope.checkTreeEvent);
}
});
}
};
})在html页面中包含了以下代码:
<div id="tree" ng-show="!errorMsg" aci-tree content="options" class="aciTree" style="height:265px;overflow:auto;"></div>树的JSON可以包含在控制器中,如下所示:
var data = [{
"id":101,
"label":"Total Vehicle Range",
"inode":true,
"checkbox":false,
"radio":false,
"branch":[{
"id":102,
"label":"75 miles",
"inode":false,
"checkbox":false,
"radio":true
},
{
"id":103,
"label":"300 miles",
"inode":false,
"checkbox":false,
"radio":true
},
{
"id":104,
"label":"500 miles",
"inode":false,
"checkbox":false,
"radio":true
},
{
"id":105,
"label":"700 miles",
"inode":false,
"checkbox":false,
"radio":true
}]
}];
scope.options = {
rootData: data,
checkbox: true
};希望这能帮到别人!
https://stackoverflow.com/questions/39770919
复制相似问题