0

I have the following code:

$scope.listaOcorrencias = TesteServico.getListaOcorrencia();
//This generate $scope.listaOcorrencias.list with data
//but if i try to read the $scope.listaOcorrencias.list give error
console.log($scope.listaOcorrencias.list);  //returns undefined
$scope.listaOcorrencia = $scope.listaOcorrencias.list; //undefined too

Really don´t know what to do.

console.log($scope.listaOcorrencias) returns:

Resource {$promise: Object, $resolved: false, $get: function, $save: function, $query: function…}
$promise: Object
$resolved: true
list: Array[1]
__proto__: Resource

the TesteServico.getListaOcorrencia():

return $resource('http://127.0.0.1:8080/teste/:classe/:action', {}, {
        getListaOcorrencia: { method: 'GET', params:{classe: 'Ocorrencia', action: 'listaDeAssuntos'}, headers : { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }
}
Bedabliu
  • 1
  • 2
  • `console.log($scope.listaOcorrencias)` what is the output? – tymeJV Apr 01 '14 at 15:55
  • 1
    What does `TesteServico.getListaOcorrencia()` look like? – Anthony Chu Apr 01 '14 at 15:55
  • possible duplicate of [How to return the response from an AJAX call?](http://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-ajax-call) – raina77ow Apr 01 '14 at 15:56
  • It appears that you are getting back a promise, show the output from: TesteServico.getListaOcorrencia().then(function(list){console.log(list)}); – Brocco Apr 01 '14 at 16:28
  • the return of TesteServico.getListaOcorrencia().then(function(list){console.log(list)}); is: TypeError: Object # has no method 'then' – Bedabliu Apr 01 '14 at 16:35
  • What does the data returned from the http call look like? – brianj Apr 01 '14 at 20:58

0 Answers0