$资源transformResponse不工作 [英] $resource transformResponse not working
本文介绍了$资源transformResponse不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
得到了简化 $资源
这里的例子(改编自角部位):
Got a simplified $resource
example here (adapted from Angular site):
angular.module('project', ['mongolab']);
function ListCtrl($scope, Project) {
$scope.projects = Project.test();
}
angular.module('mongolab', ['ngResource']).
factory('Project', function ($resource) {
var url, dfParams, actions;
url = 'https://api.mongolab.com/api/1/databases' + '/angularjs/collections/projects/:id';
dfParams = {
apiKey: '4f847ad3e4b08a2eed5f3b54'
};
actions = {
test: {
method: 'GET',
isArray: true,
transformResponse: function (response) {
// line is never getting called
console.log('transforming');
return response;
}
};
var Project = $resource(url, dfParams, actions);
return Project;
});
问题是行的console.log('转化')
从不获取调用。这是为什么?其他一切工作正常。
The question is that the line console.log('transforming')
is never getting called. Why is that? Everything else works fine.
现场小提琴 rel=\"nofollow\">。
Live fiddle here.
推荐答案
此功能仅在1.1.2或更高版本AngularJs可供选择。它是不是在1.1.1或更早版本AngularJs可用
This functionality is only available in the 1.1.2 or later versions of AngularJs. It is not available in the 1.1.1 or earlier versions of AngularJs.
这篇关于$资源transformResponse不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文