0
我的HTML代码是:AngularJS UI引导预输入从未显示结果
<p>
<input type="text" ng-model="destination" placeholder="Destination"
uib-typeahead="dest as dest.name for dest in getDestinations($viewValue)" typeahead-loading="loadingDestinations"
typeahead-no-results="noResults" typeahead-min-length="3">
<i ng-show="loadingDestinations">...</i>
<div ng-show="noResults">
<i>xxx - </i> No Destinations Found
</div>
</p>
而且我getDestinations()函数,该函数返回一个HttpPromise:
$scope.getDestinations = function(viewValue) {
console.log(viewValue);
return $http.get('/api/destAutoComplete', {
params : {
prefix: viewValue,
countryId: 94
}
});
}
它返回输入的响应“IST “从服务器:
[
{
"name": "Costa del Sol/Istan",
"cityId": 5452,
"locationId": 30083
},
{
"name": "Istanbul",
"cityId": 1122,
"locationId": null
}
]
当你看到服务器正确过滤结果作为json数组,但键入从不显示结果,并始终显示“找不到目的地”。我究竟做错了什么?我试图在“typeahead”下拉列表中将“name”显示为标签,并在选择其中一个时将整个dest对象设置为范围内的目标。