我正在尝试在AngularJS中使用jstree(http://www.jstree.com/)。我用jQuery Link做了一个简单的例子。我将该插件集成到角度,但它没有显示我的数据。为什么呢?
<div ng-controller="TestCtrl" ng-app="jsTreeApp">
<br />
<br />
<br />
<jstree data="fff"></jstree>
</div>
</body>
我可以像在小提琴中一样在树视图中添加静态数据吗?
答案 0 :(得分:0)
我使用你的Plunker使用AngularJS创建一个jstree。您的代码var app = angular.module('jsTreeApp', ['jstree']);
将导致错误,因为jstree
插件不是Angular模块。所以我删除了它。
您是正确的,您需要使用指令来呈现树。我还修改了你的数据,以便正确渲染。参见示例数据:
$scope.treeData = {
"data": [{
"text": "Basics",
"state": "open",
"children": [
{
"text": "login",
"state": "closed",
"children": [
"login",
{
"text": "results",
"state": "open"
}
]
}, {
"text": "Basics",
"state": "closed",
"children": [
"login",
"something",
{
"text": "results",
"state": "closed"
}
]
}]
}, {
"text": "All",
"state": "closed",
"children": [{
"text": "AddCustomer",
"state": "closed",
"children": [
"login",
"Add",
{
"text": "results",
"state": "closed"
}
]
}]
}]
}