Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // save images
  2.                     const asyncArray = [];
  3.                     for (var _i in img_data) {
  4.                         var _meal_index = img_data[_i].meal_index;
  5.                         var _meal_image = img_data[_i].meal_image;
  6.                         asyncArray.push($scope._saveMealImageByAPI(_meal_index, _meal_image));
  7.                     }
  8.                    
  9.                     Promise.all(asyncArray)
  10.                         .then(
  11.                             function () {
  12.                                 console.log(1);
  13.                                 // images are saved
  14.                                 $scope._saveProgressInfo.status = 'Сохранение завершено';
  15.                                 $scope._saveProgressInfo.step = $scope._saveProgressInfo.steps;
  16.  
  17.                                 // Закрыть модалку
  18.                                 $scope.$root.is_loading = false;
  19.                                 $scope.$root.addAlert("Рацион успешно сохранен", "success", 5000);
  20.  
  21.                                 // TODO: verify
  22.                             },
  23.                             function () {
  24.                                 $scope.$root.is_loading = false;
  25.                                 $scope.$root.addAlert("Ошибка при сохранении изображений", "danger", 5000);
  26.                             }
  27.                         ).then(
  28.                             function () {
  29.                                 console.log(2);
  30.                                 console.log($scope.last_meal_save_data);
  31.                                 $scope.getMealData();
  32.                             }
  33.                         );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement