2016-04-11 20 views
1

Veri kuponunun adı ng-modeldir. ng-modelini api'ye gönderirim ve yanıtı aldım yanıtı aldım. yan dışarı data.value tanımsızyanıt verisi tanımlandı ama data.value tanımlanmamış mı?

olsun ve ben dataresult.offerprice

mainCtrl.controller("MainController",function(,$scope,$rootScope,$q) 
$scope.ResultInfo=function(){ 

var couponres=$resource("http://demo.foodzard.in/api/promocode?code="+$scope.coupon.offer) 

    return couponres.get(function(data){ 
     console.log(data); 
    $rootScope.coupon=data; 
     return data; 
    }); 
     } 
     dataresult=$scope.ResultInfo(); 
     console.log(dataresult); 
     console.log(dataresult.offerprice); 

$scope.list={"hascoupan","coupanvalue":dataresult.offerprice ,"coupanamt":dataresult.offerprice,"ordertotal": $scope.Total()}; 

dataresult gibi liste nesnesinde cevabı kullanın: Tepki

Resource {offerid: "6", offerprice: "30", $promise: Promise, $resolved: true} 
$promise: Promise$resolved: trueofferid: "6"offerprice: "30" 
__proto__: Object2 

dataresult.offerprice:Response 

undefined 

dışında veri almak nasıl söyle lütfen

cevap

1

Yalnızca yanıtı aldıktan sonra erişebilirsiniz, yani - başarılı bir şekilde geri arama:

+0

Önerileriniz için teşekkürler. projem @ T J için çalışıyor – SrinivasAppQube