Javascript NickPerkins London angular treeview expand_all()问题

Javascript NickPerkins London angular treeview expand_all()问题,javascript,angular,treeview,Javascript,Angular,Treeview,我正在使用这个有角度的treeview项目: 我认为这个treeview没有函数可以在treeview上进行搜索,所以我使用一个表单来实现我的,并编写标签来查找 <form name="searchForm" novalidate style="margin-bottom: 50px"> <div> <input ng-model="search" type="text" class="form-control" placeholder="Buscar..

我正在使用这个有角度的treeview项目:

我认为这个treeview没有函数可以在treeview上进行搜索,所以我使用一个表单来实现我的,并编写标签来查找

<form name="searchForm" novalidate style="margin-bottom: 50px">
    <div> <input ng-model="search" type="text" class="form-control" placeholder="Buscar..." name="searchTerm" required /> 
    </div> 
</form>
函数“updateFilteredResponse”过滤原始数据集(从json读取)上带有包含newTerm标签的节点,并返回一个包含要在treeview中显示的项的数组

“updateTree”函数使用此数组并将数组中的自定义项转换为treeview项以添加到treeview中。此项目将添加到 $scope.tree_data=[]

这个数组使用abn tree指令:

<abn-tree tree-data="tree_data" tree-control="my_tree" ng-if="loaded" expand-level = "2"></abn-tree>
当用户点击按钮展开整个搜索结果时,效果很好。我需要在搜索后自动展开树状视图,并移除“全部展开”按钮

为此,我尝试调用我的_树。在我的控制器中展开_all()。我试过不同的电话:

$scope.my_tree.expand_all();
tree.expand_all();
在控制器和html的不同部分(使用ngIf和onload指令)。甚至我也尝试对$scope.my_tree进行“监视”,以便在准备var时尝试使用expand_all()函数,但我总是遇到相同的错误:

$scope.my_tree.expand_all is not a function

有人能帮我吗?

您可以将
expand_all()
函数放入
setTimeout
函数,如下所示

   setTimeout(function() {            
        $scope.my_tree.expand_all();
        $scope.$digest();
   }, 0);      
必须这样做,因为将数据绑定到treeview时需要一些延迟时间

$scope.my_tree.expand_all();
tree.expand_all();
$scope.my_tree.expand_all is not a function
   setTimeout(function() {            
        $scope.my_tree.expand_all();
        $scope.$digest();
   }, 0);