0
我试图用angulars资源工厂获取数据,但我不太了解如何正确处理响应。
工厂:
function dataFactory($resource, ENV) {
return $resource('http://foo/bar', {
accountId: '@accountId'
},
{
getData: {
method: 'POST',
url: 'http://foo/bar',
headers: {
'Content-Type': 'application/json'
}
}
}
);
}
在服务:
function fetchRealTimeData() {
return dataFactory.getData(requestParameters).$promise;
}
在我的指令:
dataToApply = CdnAnalyticsService.fetchRealTimeData()
当我登录dataToApply,我得到这个:
我不能使用常规对象表示法来访问属性,返回undefined。
如何访问返回对象上的属性?