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

98
Views
Servicio personalizado que no da el resultado deseado en el controlador en AngularJS 1.8

Tengo que depurar un fragmento escrito en AngularJS.

 //===== service == app.service('allUserService', function($http) { var config = { headers: { 'X-XSRF-TOKEN': gettingValueFromSomewhere() } }; this.getAll = function() { var restUrl = CONTEXT_PATH + '/rest/path/mypath'; return $http.get(restUrl, config).then(function(response) { console.log(response.data.body); // console prints an Array which is correct return response.data.body; }); } }); //========= controller ==== app.controller('UserCtrl', function($scope,allUserService) { var valueArray = []; valueArray = allUserService.getAll(); console.log(valueArray); $scope.faqBook = valueArray; });

allUserService : Obtengo el resultado correcto del servicio web Rest y el registro de la consola muestra el retorno deseado (una matriz)

faqUserCtrl : no obtengo el valor deseado en el registro de la consola. Por favor, ayúdame a encontrar el problema. Debe tener una matriz. Estoy esperando una matriz en $scope.faqBook.

Importante a tener en cuenta, cuando devuelvo una matriz codificada de allUserService , el código funciona bien

 <div class="container" ng-app="UserModule" ng-controller="UserCtrl"> <p>Search : <input type="text" ng-model="search"/></p> <table id="mainTable" class="table table-striped table-hover"> <tr ng-repeat="x in faqBook | filter:search"> <td><ul class="list-group"><li class="list-group-item">Question: {{ x.question }}</li><li class="list-group-item"> Answer: {{ x.answer }}</li></ul></td> </tr> </table> </div>
about 4 years ago · Juan Pablo Isaza
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!