tchatel / angular-treeRepeat

Recursive repeater for AngularJS
Do What The F*ck You Want To Public License
115 stars 16 forks source link

How to filter an element in the tree? #7

Open ThCC opened 10 years ago

ThCC commented 10 years ago

How to filter an element in the tree?

cberg-zalando commented 10 years ago

Just use Angular's filter system when specifying the nodes for the tree. Using the sample template as an example:

<ul frang-tree>
  <li frang-tree-repeat="node in treeData | filter:myFilter">
      <div><span class="icon"
                 ng-class="{collapsed: node.collapsed, expanded: !node.collapsed}"
                 ng-show="node.children && node.children.length > 0"
                 ng-click="node.collapsed = !node.collapsed"></span>
           <span class="label"
                 ng-class="{folder: node.children && node.children.length > 0}"
                 ng-bind="node.label"
                 ng-click="action(node)"></span>
      </div>
      <ul ng-if="!node.collapsed && node.children && node.children.length > 0"
          frang-tree-insert-children="node.children  | filter:myFilter"></ul>
  </li>
</ul>