Angularjs 如何在一个typeahead选择中调用两个API

Angularjs 如何在一个typeahead选择中调用两个API,angularjs,Angularjs,我正在使用前面的角形字体:- <label>USER</label> <input type="text" name="user" ng-model="a.user" autocomplete="off" typeahead="a for a in getAllUsers($viewValue);getAllStaffs($viewValue)" typeahead-loading="loadingCodes" typeahead-no-results="

我正在使用前面的角形字体:-

<label>USER</label>
     <input type="text" name="user" ng-model="a.user" autocomplete="off" typeahead="a for a in getAllUsers($viewValue);getAllStaffs($viewValue)" typeahead-loading="loadingCodes" typeahead-no-results="noResults">
有两个功能:-一个用于获取用户名,一个用于获取员工姓名。我希望这两个函数调用相同的输入。
但是,typeahead只获取员工名单。是否有办法在同一输入中填充两个列表。

定义一个新函数,该函数同时请求和合并结果

scope.getAllNames = function(key) {
    var obj = {
        "key": key
    }

    function extract(resp) {
        return resp.data.slice(0)
    }
    if (key.length >= 2) {
        return Promise.all([
          ApiServices.getAllUsers(obj).then(extract), 
          ApiServices.getAllStaffs(obj).then(extract)
        ])
        .then(function(results) {
            return [].concat.apply([], results) 
        });
    } else {
        return false;
    }

}

出于好奇,你为什么从来没有接受过你之前问题的任何答案?我没有否决Walton Eitan,我接受答案,如果他们能在任何方面帮助我的话,您确定语法正确吗。@shreyagupta这是在您的代码ApiServices.GetAllStaff LOL中命名它的方式
scope.getAllNames = function(key) {
    var obj = {
        "key": key
    }

    function extract(resp) {
        return resp.data.slice(0)
    }
    if (key.length >= 2) {
        return Promise.all([
          ApiServices.getAllUsers(obj).then(extract), 
          ApiServices.getAllStaffs(obj).then(extract)
        ])
        .then(function(results) {
            return [].concat.apply([], results) 
        });
    } else {
        return false;
    }

}