Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
How to call transformResponse many times in Angularjs

I need to call transformResponse many times based persons array. But the following code call only the last index

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
                            };
                        });
                    }
                };
            }
        }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I found the solution by using observable $q

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!