2021年2月7日星期日

How do I access value outside of promise?

I need to access the value of rollingSubtotal outside of this scope..

var rollingSubtotal = oldOrderHandler.getOldOrders($pData.Title)               .then(function(oldPatientOrders){                    $scope.settingSharedOldData = modalHandler.sendOldModalData(oldPatientOrders);                  $scope.oldPatientOrderInfo = oldPatientOrders;                  rawCtr = oldPatientOrders.length;                  // alert(rawCtr);                  var rollingSubtotal =0;                     for (var i = 0; i < rawCtr; i++) {                                            var created = oldPatientOrders[i].Created                      var products = JSON.parse(oldPatientOrders[i].ProductInfo);                      var orderArr = {};                            prodCtr = products.length;                                                         orderArr["prodList"] = [];                                                                                                 for (var j = 0; j < prodCtr; j++) {                              productArr = {};                                   productArr["total"] = products[j].total;                              orderArr["prodList"].push(productArr);                              rollingSubtotal = rollingSubtotal + products[j].total;                          }                                                 }                     console.log(rollingSubtotal);                   return rollingSubtotal;               }, function(error) {              });   
https://stackoverflow.com/questions/66095078/how-do-i-access-value-outside-of-promise February 08, 2021 at 10:05AM

没有评论:

发表评论