我有一个观点是这样的:
<input class="form-control" type="text" name="accountNumber" ng-model="controller.order.accountNumber" typeahead-on-select="controller.onSelect($item)" typeahead="item.title + '<br />' + item.value + '<br />' + item.detail for item in controller.autoComplete($viewValue)" />
我试图将某些格式添加到返回的结果集中。在此视图上,这实际上可以很好地工作(尽管Visual Studio抱怨着双引号)。
从另一个角度来看,我进行了以下设置:
<input class="form-control" type="text" name="sku" ng-model="controller.orderLine.sku" typeahead-on-select="controller.onSelect($item)" typeahead="item.value + '<br />' + item.title + '<br />' + item.detail for item in controller.autoComplete($viewValue)" />
在此视图上,中断显示为文本。
我想没人知道为什么吗?
我通过创建默认模板来解决此问题:
<a href tabindex="-1">
<div ng-if="match.model.title"><h4>{{ match.model.title }}</h4></div>
<div ng-if="match.model.value">{{ match.model.value }}</div>
<div ng-if="match.model.value">{{ match.model.detail }}</div>
</a>
我的预输入html看起来像这样:
<div class="col-xs-12 col-md-4">
<form name="searchForm" role="form">
<input class="form-control" type="text" placeholder="Search" ng-model="controller.selected" typeahead-on-select="controller.onSelect()" typeahead-template-url="template/typeahead/typeahead-account-match.html" typeahead="item.accountNumber as item for item in controller.autoComplete($viewValue)" />
</form>
</div>
注意:您可以看到我正在将typeahead-template-url设置为上面的模板。如果您的模板不太可能更改,则可以忽略该属性,而只需覆盖template / typeahead / typeahead-match.html,它将使用该属性。
我希望这对其他人有帮助:)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句