【发布时间】:2017-02-03 11:38:07
【问题描述】:
假设您有一个包含以下对象的数组:
{id: Integer, name:'String'}
以下面的数组为例:
$scope.users = [{
id: 1, name: 'Marc Edgelund main'
}]
然后您可以通过以下方式显示这些对象:
那么你有以下html:
<input type="text" ng-model="search.$"/>
<table>
<thead>
<th>id</th>
<th>Name</th>
</thead>
<tbody>
<tr ng-repeat="user in users | filter:search">
<td>
{{user.id}}
</td>
<td>
{{user.name}}
</td>
</tr>
</tbody>
</table>
现在假设您搜索字符串:Marc Main,结果将为空。
这是因为 Angular 会检查对象的值并将其与字符串匹配。然而,在上面的示例中,系统的客户端可能不会使用“中间”名称作为搜索参数,这意味着搜索将不一致并且会惹恼最终用户,因为他们将无法找到他们正在寻找的内容。
我的问题是如何创建允许上述功能的智能搜索功能?
这是一个展示我的例子的小提琴:
【问题讨论】:
-
为什么投反对票?
标签: javascript angularjs search