[英]Select-UI not populating drop down
我正在嘗試使用AngularJS Select-UI,但是在填充下拉列表時遇到了問題。 控制台上沒有顯示任何錯誤,但沒有填充下拉菜單:
HTML部分
<ui-select ng-model="selectedUser" theme="bootstrap" on-select="onSelectCallback($item)">
<ui-select-match placeholder="Select a User">{{selectedUser.username}}</ui-select-match>
<ui-select-choices repeat="item in options.people">
<div ng-bind-html="item.username | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
控制器部分:
function selectCtrl($scope, $http) {
$scope.options = {};
$scope.selectedUser = {};
var onUserComplete = function(response){
$scope.options.people = response.data;
console.log($scope.options.people);
}
$http.get("http://localhost/api/user")
.then(onUserComplete);
$scope.onSelectCallback = function(item){
$scope.selectedUser = item;
}
}
數據以數組形式返回,我通過控制台退出查看該數組:
Array(2)
0:{id: 1, username: "username1", $$hashKey: "object:130"}
1:{id: 2, username: "username2", $$hashKey: "object:131"}
length:2
__proto__:Array(0)
您嘗試過簡化版嗎?
例如:
ng-bind="item.username"
甚至通過定義$scope.options = {};
直接(也許錯誤不在then方法中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.