0

I am a newbie with Angularjs, and trying to figure it up:

in boardService there are 2 function

var getLiveCards = function () {
    return $http.get(endpointService.getLiveCards(), {})
                .then(function (response) {
                    return response.data;
                }, function (error) {
                    return $q.reject(error.data.Message);
                }
           );
};

 var getRelationshipTypes = function () {
    return $http.get(endpointService.getRelationshipTypes(), {})
                .then(function (response) {
                    return response.data;
                }, function (error) {
                    return $q.reject(error.data.Message);
                }
           );
};

and

i am trying to call a controller, with the data received from both of the functions:

 vm.relationsEdit = function (card) {
        boardService.getLiveCards()
           .then(function (data) {
               vm.liveCards = data
               boardService.getRelationshipTypes()
                   .then(function (types) {
                       vm.types = types;
                       cardRelationsModalService.relationsEdit(card, vm.liveCards, vm.types)
                       .then(function (response) {
                           console.log("Card edited: " + response);
                       });
                   })
           }, onError);
    }

When i put a break-point with chrome debugger, in that line: vm.liveCards = data, data contains data from getLiveCards but nothing is happen after that.

What am I doing wrong? how can i get data from the 2 functions and send it to cardRelationsModalService.relationsEdit function?

E.Meir
  • 2,146
  • 7
  • 34
  • 52
  • Your `getRelationshipTypes` maybe throwing an error and you do not have a error callback registered on the second `then` (inner `then`). Add an error callback to know why the call is failing – Chandermani Apr 25 '17 at 16:36
  • Thanks you helped! – E.Meir Apr 26 '17 at 07:33

0 Answers0