AngularJS - 如何筛选一堆一定的ID?AngularJS、ID

2023-09-14 23:06:30 作者:全国帅比代表

我想创建一个过滤器,例如隐藏3某些特定的ID

我的数据对象看起来像:

  $ scope.subtree = {[ID:1},{ID:2},{ID:3},{ID:4},{ID:5},{ID :6},{ID:6}] 

我得到的命令来隐藏:

  [{ID:1},{ID:4},{ID:6}] 

模板

 < UL>   <李NG重复=节点树>        &所述p为H.; node.id&下; / P>   < /李>< UL> 
如何下载angularjs

解决方案

使用过滤器,或在示波器上的功能。

 数据-NG-重复=子树节点| idFilter:[1,4,6]数据-NG-重复=子树节点|过滤器:hideIds([1,4,6]) 

这样

I want to create a filter that hides e.g. three certain IDs given.

My data object look like that:

$scope.subtree = [{id: 1},{id: 2},{id: 3},{id: 4},{id: 5},{id: 6},{id: 6}]

I get the command to hide:

[{id: 1},{id: 4},{id: 6}]

Template

<ul>

   <li ng-repeat="node in subtree"> 
        <p>node.id </p>
   </li>

<ul>

解决方案

Use filters, or a function on a scope.

data-ng-repeat="node in subtree | idFilter:[1,4,6]"

data-ng-repeat="node in subtree | filter:hideIds([1,4,6])"

Something like this

 
精彩推荐
图片推荐