how to get response of 2 api calls in angular js with $q.all and service

后端 未结 1 1879
感情败类
感情败类 2021-01-29 00:23

i want to call 2 api and want to store the response in the scope variable. but im not able to get the data in the scope variable. im using $q.all and service for calling the api

1条回答
  •  温柔的废话
    2021-01-29 00:50

    function loadData() {
         var promises = [
              doorService.get(),
              waterService.get()
         ];
         $q.all(promises).then(function (resp) {
            $scope.DoorData= resp[0].data;
            $scope.WatertankData= resp[1].data;
            $scope.combineResult = {
                'DoorData': resp[0].data,
                'WatertankData':resp[1].data
            };
         });
     }
    

    0 讨论(0)
提交回复
热议问题