AngularJs在搜索表单中按列类型过滤

问题描述:

我有一个使用ng-repeat的角度列表表。我也有一个搜索所有列的标准搜索表单。AngularJs在搜索表单中按列类型过滤

<tr ng-repeat="item in test | filter: criteria"> 

<input type="search" placeholder="Search" ng-model="criteria"> 

是否有可能延长searchform的功能,这样我可以指定列名,后跟一个冒号,然后searchphrase只在该列中搜索?见下面的例子

Searchterms:

"Description: my awesome description" 
// This will search in the description-column for "my awesome description" 

"my awesome description" 
// This will search in all columns for "my awesome description" 

所以以某种方式寻找一个冒号,如果发现改变以某种方式过滤器。

+0

为此创建自定义过滤器。参考link 2014-09-30 11:47:47

filter:{'description':criteria} 

你可以尝试这样的事情:

<input type="text" ng-model='test.age'> Age<br> 

<input type="text" ng-model='test.about'> about<br> 
<hr> 

<table class="table table-striped"> 
    <tr ng-repeat='item in appVm.users |filter:test'> 
    <td>{{item.name}}</td> 
    <td>{{item.age}}</td> 
    <td>{{item.about}}</td> 

    </tr> 

看到它在行动in this plunk

有何帮助还不够吗?