Check out the code snippet provided below.
directive:
app.directive("filterTree", function() {
return {
restrict: "AE",
controller: function($scope, $http){
$scope.treeNodes = [];
var filterItemsUrl = "/api/v1/users/userId/filter_nodes";
$http.get(filterItemsUrl).success(function(response) {
var filterItems = response["data"]["filter_nodes"];
filterItems.map(function(item){
$scope.treeNodes.push({
id: item.id,
pId: item.pid,
name: item.name,
open: item.open,
checked: item.checked
});
});
});
},
link: function(scope, element, attributes, controller){
var setting = {
check: {
enable: true
},
data: {
simpleData: {
enable: true
}
}
};
$.fn.zTree.init(element, setting, scope.treeNodes);
}
};
});
html:
<ul class="ztree" filter-tree="" id="filterTree"></ul>
The isolated scope variable scope.treeNodes
seems to be unavailable in my link function. Can someone provide guidance on how to access this specific scope variable within the link function?