I'm using ngjstree (https://github.com/ezraroi/ngJsTree) and i would like populate tree with an Ajax call; i looked up documentation and some examples, but i didn't find anything helpful. I know that is similar to jsTree, and checked out the documentation, i found that is possible populate the tree in this way:
$('#tree').jstree({
'core' : {
'data' : {
'url' : function (node) {
return node.id === '#' ?
'ajax_roots.json' :
'ajax_children.json';
},
'data' : function (node) {
return { 'id' : node.id };
}
}
});
In ngjstree i can't call my tree in the same way ($('#tree').jstree
), because i have a different structure. in particular case, i have this html:
<div ng-controller="treeCtrl as vm">
<div js-tree="vm.treeConfig" ng-model="vm.treeData" tree="vm.treeInstance"></div>
</div>
I try to populate tree in the controller like this:
vm.treeData = {
core : {
html_titles : true
},
plugins : ["themes", "json_data", "ui"],
json_data : {
"ajax" : {
"url" : myUrl,
"data" : function (n) {
return {
id : n.attr ? n.attr("id") : 0,
node_type : n.attr ? n.attr("rel") : '',
site_id: n.attr ? n.attr("site_id") : ''
};
}
}
}
But this return always a tree with only one node, while if I open the same ajax call on browser, return more nodes.
Is it possible make the same things like jstree? am i doing any errors?
Sorry for the trivial question, but I'm a beginner about it.
Thanks in advance
Regards