Angular tree control -— filter the nodes of a tree

那年仲夏 提交于 2020-01-06 05:19:22

问题


I am following the link https://wix.github.io/angular-tree-control/ to explore different features of angular tree control.From the documentation could not properly understand what values i should give for filter comparator and filter expression to make it work in order to filter the nodes.Below is the code:

<body ng-app="app">
Search: <input ng-model="searchTree">
<table id="searchTextResults">
<tr><th>Name</th><th>Age</th></tr>
<tr ng-repeat="data in dataForTheTree | filter:searchTree">
<td>{{node.name}}</td>
<td>{{node.age}}</td>
</tr>
</table>
<div ng-controller="myController">
<treecontrol class="tree-light"
tree-model="dataForTheTree"
filter-expression="data" 
filter-comparator="false"
options="treeOptions"
on-selection="showSelected(node)"
selected-node="node1">  {{node.name}} age {{node.age}}
</treecontrol>
</div>
</body>

Full link for plunkr : https://plnkr.co/edit/bQHOIQ2HDPr4WJaukB8I?p=preview


回答1:


In here we can use filter-expression it is just like ng-repeat | filter:{} option

filter-expression="{filterable column: ng-model name}"

ex - filter-expression="{name: searchByName}"

and we can use

filter-comparator="true"
filter-comparator="false"


来源:https://stackoverflow.com/questions/51870645/angular-tree-control-filter-the-nodes-of-a-tree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!