Ui.Bootstrap Typeahead不能使用Async调用

我正在使用ui.bootstrap typeahead与asynchronous调用。 然而,由此产生的数据似乎没有find方式返回到前面的指令,随后没有下拉与数据出现。

该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"> 

JSfunction在这里

 $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帆来查询后端。 我已经用ui.bootstrap文档中给出的示例testing了代码,并且一切正常。

$ sails.get也可以用作console.log(item.username)打印出来的值。

我有一种感觉,它与getSearch函数中的承诺有关。

任何想法,为什么下拉不出现?

我更新了从10.5到11的风帆。随后客户端SDK改变(Sails.io)和我使用Angular-Sails的angular库也需要更新。

承诺function改变了,我需要更新它。 改变承诺函数到下面的问题。 现在typeahead函数得到一个响应,下拉菜单出现。

  return $sails.get("/search/" + val) .then(function (response) { console.log(response); return response.data.map(function (item) { return item.username; }); }, function (response) { alert('Houston, we got a problem!'); });