【发布时间】:2016-01-12 15:40:22
【问题描述】:
我有一个预先输入的搜索,我正在显示对象的名称、城市和州属性。但过滤器仅应用于名称。当我在搜索框(文本框)中输入字符时,它会列出所有匹配的名称,包括名称、城市和州,如果字符匹配城市或州,这些也会突出显示。我不想突出显示城市和州。
请帮忙。
【问题讨论】:
我有一个预先输入的搜索,我正在显示对象的名称、城市和州属性。但过滤器仅应用于名称。当我在搜索框(文本框)中输入字符时,它会列出所有匹配的名称,包括名称、城市和州,如果字符匹配城市或州,这些也会突出显示。我不想突出显示城市和州。
请帮忙。
【问题讨论】:
<div ng-repeat="your variables here | filter:name">
希望这会对你有所帮助。
【讨论】:
<input type="text" ng-model="clinic.name" typeahead="clinic.id + '' + clinic.name + ' ' + clinic.city + ' '+ clinic.state for clinic in getClinics($viewValue) | filter:{name: $viewValue} | filter:{deleted: false}" typeahead-on-select="showAssociateClinicModal($item)" typeahead-template-url="customclinicTypeaheadTemplate.html">
<script type="text/ng-template" id="customclinicTypeaheadTemplate.html">
<a>
<span ng-bind-html="match.model.id"></span>
<span ng-bind-html="match.model.name | typeaheadHighlight:query"></span>
<span ng-bind-html="match.model.city"></span>
<span ng-bind-html="match.model.state"></span>
</a>
</script>
getClinics 是控制器中的一个方法,它返回一个 cinics 数组
【讨论】: