我查看了關於Async typeahead的官方article and sample。 當我簡化並將它存根並用於我的項目。Angular.JS中的Async typeahead不顯示選項
angular.module('ui.bootstrap.demo', ['ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('TypeaheadCtrl',
function($scope, $http) {
$scope.placeHolder = "Choose";
$scope.displayPath = "Name";
$scope.typeaheadminlen = 3;
// Any function returning a promise object can be used to load values asynchronously
$scope.loadOptions = function(val) {
var stub = [{ Name: "fuuuu" }, { Name: "baaar" }];
if (!$scope.selected)
return [];
return $http.get('http://maps.googleapis.com/maps/api/geocode/json', {
params: {
address: "aa",
sensor: false
}
})
.then(function(response){
return stub;
});
};
});
http://plnkr.co/edit/o4ly4vYJdGCwHk62tN2j?p=preview
此代碼的工作就plunker不夠好,但不是在我的項目。不知何故,它只有幾次。其他時候我只看到glyphicon-refresh
,但選項還沒有出現。斷點說我正確地得到了我的return stub;
。版本號Angular.JS
和Bootstrap
與我的項目版本匹配。任何想法我可能會錯過什麼?
P.S. div-tag
的範圍和內容在項目和搶劫者之間完美複製。