【问题标题】:Angular typeahead highlight all properties that are shownAngular typeahead 突出显示显示的所有属性
【发布时间】:2016-01-12 15:40:22
【问题描述】:

我有一个预先输入的搜索,我正在显示对象的名称、城市和州属性。但过滤器仅应用于名称。当我在搜索框(文本框)中输入字符时,它会列出所有匹配的名称,包括名称、城市和州,如果字符匹配城市或州,这些也会突出显示。我不想突出显示城市和州。

请帮忙。

【问题讨论】:

    标签: angularjs typeahead


    【解决方案1】:
    <div ng-repeat="your variables here | filter:name">
    

    希望这会对你有所帮助。

    【讨论】:

    • 感谢您的回复。但上述解决方案对我不起作用。 这是我的文本框,仅在输入时应突出显示名称中的名称字符。
    • 很好。请尝试使用您的 ng-model。像这样 |过滤器:人名
    【解决方案2】:
    <input type="text" ng-model="clinic.name" typeahead="clinic.id + '' + clinic.name + '&nbsp;&nbsp;' + clinic.city + '&nbsp;&nbsp;'+ 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 数组

    【讨论】:

      猜你喜欢
      • 2017-09-25
      • 2023-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-24
      • 1970-01-01
      • 2021-10-09
      相关资源
      最近更新 更多