【问题标题】:AngularJs filter by typed column in searchformAngularJs按搜索表单中的输入列过滤
【发布时间】:2014-09-30 11:37:56
【问题描述】:

我有一个使用 ng-repeat 的角度列表。我还有一个搜索所有列的标准搜索表单。

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

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

是否可以扩展搜索表单的功能,以便我可以指定列名后跟冒号,然后指定搜索短语以仅在该列中搜索?请参阅下面的示例

搜索词:

"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"

因此以某种方式查找该冒号,如果找到,请以某种方式更改过滤器。

【问题讨论】:

标签: javascript angularjs filter


【解决方案1】:
filter:{'description':criteria}

【讨论】:

    【解决方案2】:

    你可以试试这样的:

    <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

    这是否足够帮助?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-20
      • 2010-12-18
      • 1970-01-01
      • 2020-02-21
      • 2018-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多