0
How do I pass the contents of the service JSON object to controller.
At the moment I do tests with the following codes:
Controller(app.js)
  example.controller('equipecontrol', ['EquipeService','$scope', function( EquipeService,$scope) {      
Parse.initialize('APPLICATION_ID', 'JAVASCRIPT_KEY'); 
Parse.serverURL = 'https://parseapi.back4app.com';
EquipeService.$inject = ['EquipeService']; // Injetamos o service
equipes =  { "nomejogador": '',
             "posioriginal":'',
             "nomedotime": '',
             "jogoude": ''
            };
listaobjEquipes = EquipeService.listaobjEquipes;   <--- NESTE MOMENTO O OBJETO ESTÁ RETORNANDO VAZIO
...
Service(service.js)
var example = angular.module('starter')
example.service('EquipeService', ['$http', function($http) {
  var aDadosEscalacao = {};
  return { listaobjEquipes: aDadosEscalacao,
        get: function(param) {
          var nteste = 1
          if (neste = 1) {
            idjogador = '1';
            idtime = '1';
            idjogoude = '1';
            idpelada = '1';
            ngolsjogador = '207';
            faltastxtJSON = '1';
            ncrtamarelos = '1';
            ncrtvermelhos = '1';
            nptoscraque = '18';
            nptosdestaque = '19';
            nptosmaster = '21';
            nptosgoleiro = '12';
            aDadosEscalacao = { "idjogador": idjogador, 
                                "idtime": idtime,
                                "idjogoude": idjogoude,
                                "idpelada": idpelada,
                                "gols": ngolsjogador,
                                "faltas": faltastxtJSON,
                                "cartao_amarelo": ncrtamarelos,
                                "cartao_vermelho": ncrtvermelhos,
                                "pontuacaocraque": nptoscraque,
                                "pontuacaodestaque": nptosdestaque,
                                "pontuacaomaster": nptosmaster,
                                "pontuacaogoleiro": nptosgoleiro };
          }
          return aDadosEscalacao
        }
  }
}])
I ask, what is wrong with the code that cannot pass the content of JSON completed for the controller?
Okay Leandro, it just worked by implementing get() as you directed. I would also like to record another form that was made and worked as well: it was following the guidelines of the video posted on this link https://www.youtube.com/watch?v=i2_k4ECZrTI the code went like this ... https://www.youtube.com/watch?v=i2_k4ECZrTI and in the controller listobjEquipes = Equipeservice.getEscalacao(); I decided to leave registered only to add our knowledge bank. In short I find your answer cool, because I don’t need to change anything in service.js, just in the controller. Thanks again!
– Ita
good afternoon! after this solution found, I edited my codes and implemented parse.query instructions in service.js, the method I am using now is getEscalation, however it cannot transmit the contents of the aDadosEscalation object to the controller.
– Ita
@Ita opens another issue with the full and updated code there. It’s easier to understand the problem.
– Leandro Oriente
I already did, follow the link http://answall.com/questions/193295/como-passar-um-conte%C3%bado-de-json-object-to-a-controller-part-2-using-pair
– Ita