问题
当使用来自GET
的$resource
请求时,成功的响应仅是9中的空数组。
测试
成功情景:
GET
请求将返回开发和本地环境中的数据数组。失败的情景:
调试步骤:
结果
问题
可能的相关资源
代码
资源
var AnswerSetBySubjectByForm = function($resource) {
return $resource('/rest/answerset/subject/:idSubject/form/:idForm',
{ idSubject : '@idSubject', idForm : '@idForm'},
{'get' : {method:'GET', isArray:true}}
);
};
控制器
var AnswerSetController = function($scope, AnswerSetBySubjectByForm) {
...
$scope.$on('loadAnswerSets', function(e, idSubject, idForm) {
if (angular.isNumber(idSubject) && angular.isNumber(idForm)) {
AnswerSetBySubjectByForm.get({
idSubject : idSubject,
idForm : idForm
}, function(answerSets) {
/* answerSets is an empty array in IE9 only */
$scope.answerSets = angular.copy(answerSets);
});
}
});
...
应用程序
...
app
.factory('AnswerSetBySubjectByForm',
['$resource', AnswerSetBySubjectByForm])
.controller('AnswerSetController',
['$scope', 'AnswerSetBySubjectByForm', AnswerSetController])
...
任何帮助调试这将是非常感谢的!提前谢谢。
发布于 2014-04-08 06:41:07
在您的角度代码中这样做,以防止缓存GET请求。
app.config(['$httpProvider', function ($httpProvider) {
//Disable caching and make sure the call is made for each GET request.
//Especially for IE, disable ajax get request caching
$httpProvider.defaults.headers.get = $httpProvider.defaults.headers.get || {};
$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
$httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
}]);
https://stackoverflow.com/questions/22871236
复制相似问题