Denetleyici verilerim. coupon.offer, api için ng modelidir. Yanıt bir dizi var. $ rootScope.Result veri dizisidir ancak $ rootScope.Result.offerprice = undefined. nasıl bu verileri almak için
mainCtrl.controller("OrderController",function($scope,$rootScope){
couponres=$resource("http://demo.foodzard.in/api/promocode? code="+$rootScope.coupon.offer)
if($scope.Total()>=400)
{
$rootScope.Result=couponres.get(function(data){
console.log(data);
return data;
});
console.log($rootScope.Result);
console.log($rootScope.Result.offerprice)
Yanıt: ben bu
var couponres=$resource("http://demo.foodzard.in/api/promocode?code="+$rootScope.coupon.offer)
if($scope.Total()>=400)
{
$rootScope.Result=couponres.get().$promise.then(function(data){
console.log(data);
return data;
});}
ama sen çalışıyorsun bu
'$ resource' tanımla uyumsuz olan AJAX. İstek tamamlanmadan önce verilere erişemezsiniz – charlietfl