Javascript AngularJS UI Typeahead-设置结果属性之一的样式
我一直在用它来指导我使用奇妙的typeahead指令 但是我有点被卡住了。我需要对结果中的一个属性应用样式设置 我有一个Javascript AngularJS UI Typeahead-设置结果属性之一的样式,javascript,angularjs,angularjs-directive,angular-ui-typeahead,Javascript,Angularjs,Angularjs Directive,Angular Ui Typeahead,我一直在用它来指导我使用奇妙的typeahead指令 但是我有点被卡住了。我需要对结果中的一个属性应用样式设置 我有一个plunker 我的问题是,我不太明白如何将类应用于结果末尾显示的supervisor.address属性 HTML如下所示 <div class="container-fluid" ng-controller="TypeaheadCtrl"> <div>Selected: <span>{{selected}}</spa
plunker
我的问题是,我不太明白如何将类应用于结果末尾显示的supervisor.address属性
HTML
如下所示
<div class="container-fluid" ng-controller="TypeaheadCtrl">
<div>Selected: <span>{{selected}}</span></div>
<div><input type="text" ng-model="selected" typeahead="supervisor as supervisor.firstname +' '+supervisor.surname+''+' ('+supervisor.address+')' for supervisor in supervisors | filter:{firstname: $viewValue}:startsWith | limitTo: 8" typeahead-template-url="itemTpl.html"></div>
</div>
已选定:{{Selected}
要做到这一点,您需要拆分结果元素:
<script type="text/ng-template" id="itemTpl.html">
<a tabindex="-1">
<span ng-bind-html-unsafe="match.model.firstname+' '+match.model.surname+'' | typeaheadHighlight:query"></span>
<span style="font-weight: bold;" ng-bind-html-unsafe="'(' + match.model.address +')' | typeaheadHighlight:query"></span>
</a>
</script>
祝你好运这在你的车里对我有用:
<span ng-bind-html-unsafe="match.model.firstname+' '+match.model.surname+''+' (<i>'+match.model.address+'</i>)' | typeaheadHighlight:query"></span>
您不必使用i标记。plunkr中的typeahead模板在哪里?很抱歉,我链接到了错误的plunker。这一点现已更新。谢谢,谢谢你。一旦选择了输入值,我将如何将其扩展到输入值?别担心,我刚刚意识到这是不可能的。谢谢