Necesito llamar a transformResponse muchas veces según la matriz de personas. Pero el siguiente código llama solo al último índice
function fill() { var persons = [ { id: 34, text: $translate.instant("enter") }, { id: 36, text: $translate.instant("high") }, { id: 53, text: $translate.instant("graduates") }, { id: 35, text: $translate.instant("persons") }, ] var personSubCategoriesList = []; for (var i = 0; i < persons.length; i++) { $scope.remote = { url: window.config.apiHostUrl + `lookup/Get?id=${persons[i].id}`, transformResponse: function (data) { var personSubCategories = angular.fromJson(data); angular.forEach(personSubCategories, function (personSubCategoriesObjet) { var categories = { name: personSubCategoriesObjet.localizedName, code: personSubCategoriesObjet.id }; personSubCategoriesList.push(categories); }); return personSubCategoriesList.map(function (adminCategories) { return { name: adminCategories.name, code: adminCategories.code }; }); } }; } }
Encontré la solución usando $q observable