【发布时间】:2016-10-16 18:26:47
【问题描述】:
我有一个 UI-Bootstrap 的字头,但是当收到数据时,下拉菜单不显示。
$scope.obtainUsers = function (valor) {
console.log(valor)
$http({
method: "POST",
url: "http://localhost:3000/obtainUsers",
params: {"valor": valor}
}).then(function successCallback(response){
console.log(response.data);
return response.data;
}, function errorCallback(error){
alert("ERROR")
})
}
还有 HTML
<input type="text" ng-model="selectedValue" uib-typeahead="userName as userName.userName for userName in obtainUsers($viewValue)" typeahead-loading="loadingUsers" typeahead-no-results="noResults" class="form-control">
<i ng-show="loadingUsers" class="glyphicon glyphicon-refresh"></i>
<div ng-show="noResults">
<i class="glyphicon glyphicon-remove"></i> No Results Found
</div>
我在 ng-options 上使用了相同的 sintax,效果很好,但在打字头上没有。
编辑:啊,当然,HTTP 获得一个这样的数组 [{用户名:佩德罗},{用户名:玛丽亚},...]
【问题讨论】:
标签: angularjs twitter-bootstrap angular-ui-bootstrap angular-ui-typeahead typehead