sea​​rchKeyword不是AngularJS过滤器工作 [英] searchKeyword not working in AngularJS filter

查看:288
本文介绍了sea​​rchKeyword不是AngularJS过滤器工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写使用的前端AngularJS的应用程序。我想通过任何文字/字段的表进行搜索;一切一个搜索框。根据这篇文章在这里: http://hello-angularjs.appspot.com/searchtable
我可以使用过滤器:searchKeyword做只是这。

I am writing an app using AngularJS on the front end. I want to search through a table by any word/field; one search box for everything. According to this article here: http://hello-angularjs.appspot.com/searchtable I can use filter: searchKeyword to do just this.

这是我的code,并预期它不工作。

This is my code, and it is not working as expected.

<label>Search: <input ng-model="searchKeyword"></label>

<table ng-repeat="post in posts | orderBy: sort | filter: searchKeyword">
    <tr>
       <td> {{index(post)}} </td>

       <td> {{post.title}} </td>

       <td> {{post.author}} </td>

       <td> {{post.content}} </td>

       <td> {{post.date | date: "d/M/yyyy"}} </td>
    </tr>
</table>

我应该怎么办?谢谢

What should I do? Thank you

推荐答案

我遇到了类似的问题我自己。

I ran into a similar issue myself.

我做了这样的事情。

<input class="form-control" type="text" ng-model="searchFilter.itemDesc" 
    placeholder="Search...." />

<tr ng-repeat="item in items | filter: searchFilter">

每个项目都有itemDesc的属性。

each item has a property of itemDesc

这样做的缺点方法是,它只是让你搜索正在重演对象的一个​​属性。

the downside to this approach is that it only lets you search one property of the object being repeated

如果你想要它由对象的不同属性。

If you are wanting it to be searched by the different properties of the object

您可以做类似的东西。

<一个href=\"http://stackoverflow.com/questions/13216115/filtering-by-multiple-specific-model-properties-in-angularjs-in-or-relationship\">Filtering在AngularJS

这篇关于sea​​rchKeyword不是AngularJS过滤器工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆