需要帮助首先加载静态标记并同时点击后端API以获取建议列表作为自动完成loadTags函数的一部分,因为它仅适用于函数的第一次返回,所以我要么能够命中后端并返回列表或我能够返回静态列表;
function loadTags(query) {
myLocalTags = _.merge(filteredBasicTags, filteredAdvTags);
apiService.getBackendTags(query).then(function(response) {
myLocalTags = _.values(_.merge(myLocalTags, response.data));
return myLocalTags;
});
//so either I am able to return the apiService Response or the myLocalTags Data for the autocomplete suggestions.
return myLocalTags;
}
答案 0 :(得分:0)
您可以这样做:
$scope.autocompleteSuggestions = _.merge(filteredBasicTags, filteredAdvTags);
apiService.getBackendTags(query).then(function(response) {
myLocalTags = _.values(_.merge(myLocalTags, response.data));
$scope.autocompleteSuggestions = myLocalTags;
});