【发布时间】:2015-06-17 01:43:04
【问题描述】:
我正在使用带有异步调用的 ui.bootstrap typeahead。然而,生成的数据似乎并没有找到返回 typeahead 指令的方法,随后数据也没有出现下拉菜单。
html是
<input type="text" ng-model="asyncSelected" placeholder="Search Profile" typeahead="username.username for username in getSearch($viewValue)" typeahead-wait-ms="400" class="form-control">
还有JS函数在这里
$scope.getSearch = function (val) {
return $sails.get("/search/" + val).success(function (response) {
console.log(response);
return response.map(function (item) {
console.log(item.username);
return item.username;
});
}).error(function (response) {
console.log('The sails profile search has failed');
});
}
响应 JSON 对象是
Object
@type: "d"
id: "#17:3"
username: "Burt"
__proto__: Object
我在客户端使用 angular-sails 来查询后端。我已经使用 ui.bootstrap 文档中给出的示例测试了代码,一切正常。
$sails.get 也可以作为 console.log(item.username) 打印出值。
我感觉它与 getSearch 函数中的承诺有关。
任何想法为什么下拉菜单没有出现?
【问题讨论】:
标签: angularjs node.js sails.js angular-bootstrap angular-ui-typeahead