2016-04-11 67 views
1

以下のデータクーポンはNGモデルです。私はAPIにngモデルを送り、私はresponse.in側に得られた総応答を得ました。サイドからdata.value未定義応答データは定義されていますが、data.valueは定義されていませんか?

を取得し、私は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ようなリストオブジェクト内の応答を使用します。レスポンス

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

dataresult.offerprice:Response 

undefined 

外のデータを取得する方法を教えてください

答えて

1

あなたはそれを受け取った後でしか応答にアクセスすることができません。成功コールバックの中にあります:

return couponres.get(function(data) { 

    // Do whatever you want with the data here 

    console.log(data); 
    $scope.list = { 
    "hascoupan": true, // <-- some value should be here 
    "coupanvalue": data.offerprice, 
    "coupanamt": data.offerprice, 
    "ordertotal": $scope.Total() 
    }; 
    return data; 
}); 
} 
+0

あなたのご提案ありがとうございます。それは私のプロジェクトのために働いています@ T J – SrinivasAppQube

関連する問題