我正在尝试实现ngTagsInput,我想在其中实现电子邮件的自动搜索。为此,我写了下面的代码。但它不显示自动搜索结果
HTML:
<tags-input ng-model="compose.receiver"
add-from-autocomplete-only="true"
min-length="1">
<auto-complete source="loadReceiver($query)"
min-length="0"
debounce-delay="0"
max-results-to-show="10"
loadOnEmpty="true">
</auto-complete>
</tags-input>
控制器 :
$scope.loadReceiver = function(query){
return AdminInbox.loadReceiver(query);
}
服务 :
angular.module('inboxes').factory('AdminInbox', ['$http','$q',
function($http,$q) {
return {
loadReceiver: function(query) {
console.log(query);
var deferred = $q.defer();
var receiver = $http.get('mailreceiver/'+query);
console.log(receiver);
return deferred.promise;
}
}
}
]);
我成功地得到了以下格式的回复:
[{_id: "5579c9a4f3d71f8c2a4f1e3d" email: "abc@gmail.com"},
{_id: "557f2cd3a571f9a41e4168f2" email: "xyz@gmail.com"}]