我查看了关于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
的范围和内容在项目和抢劫者之间完美复制。