【发布时间】:2015-12-27 01:58:35
【问题描述】:
我正在使用 Angular 1.3 编写应用程序。我想通过任何单词/字段搜索表格;一个搜索框搜索所有内容。
目前,我可以通过以下方式让我的搜索框通过特定字段进行搜索:
<label>Search: <input ng-model="searchKeyword.title"></label>
或
<label>Search: <input ng-model="searchKeyword.author"></label>
那些工作正常。但是,当我尝试同时搜索所有字段时:
<label>Search: <input type = "text" ng-model="searchKeyword"></label>
它根本不起作用。
这是我在桌子上的代码:
<label>Search: <input ng-model="searchKeyword"></label>
<table ng-repeat="post in posts | orderBy: sort | filter: searchKeyword">
<tr>
<td> {{post.title}} </td>
<td> {{post.author}} </td>
<td> {{post.content}} </td>
<td> {{post.date | date: "d/M/yyyy"}} </td>
</tr>
</table>
这是在我的主控制器内部:
$scope.posts = posts.posts;
$scope.searchKeyword = "";
请告诉我究竟是什么导致了这个奇怪的错误。谢谢。
【问题讨论】:
-
我似乎无法在这里重现问题,当我测试它时,它可以正常工作。
标签: angularjs search angularjs-ng-repeat angular-ngmodel angular-filters