我的AngularUI bootstrap typeahead返回“No Results Found”,即使它应该读取一个Objects数组。
在uib-typeahead中我有uib-typeahead="number for number in getNumbers($viewValue)"
在我的控制器中我有
$scope.getNumbers = function($viewValue) {
...stuff to retrieve numbers...
return array
}
其中console.log(array)
显示[Object,Object,Object ...]
我只是想展示一些我认为相关的代码。这是问题所在吗?为什么下拉列表返回未找到结果?
<input
type="text"
class="form-control"
name="number"
ng-model="numberinfo.number"
uib-typeahead="number for number in getNumbers($viewValue)"
typeahead-template-url="/tpl.html"
typeahead-loading="Loadinglocations"
typeahead-on-select="numberSelect($item, 10)"
typeahead-wait-ms="3"
typeahead-min-length="3"
typeahead-no-results="noResults"
required>
<i ng-show="loadingLocations" class="glyphicon glyphicon-refresh">Loading...</i>
<div ng-show="noResults">
<i class="glyphicon glyphicon-remove"></i> No Results Found.
</div>
<script type="text/ng-template" id="/tpl.html">
<a>
<div>
<span style="display:block;" class="registration"
ng-bind-html="match.model.number | uibTypeaheadHighlight:query"></span>
</div>
</a>
</script>
答案 0 :(得分:0)
您的控制器正在安慰该对象,但由于此参数,您的uib-typehead无法获取该对象
$scope.getNumbers = function($viewValue)
将其更改为
$scope.getNumbers = function(viewValue)