我正在使用AngularJS创建一个RESTful单页面应用程序,并按照教程这部分代码应该可以工作:
bosApp.factory('Revision', function($resource, $http) {
return $resource('http://example.com/api/v1/articlerevision/:id/', {
id: '@is'
},
{
update: {
method: 'POST'
params: {"update": true},
isArray: false
},
save: {
method: 'PUT'
},
query: {
method: 'GET',
isArray: true,
transformResponse: tastypieDataTransformer($http)
},
create: {
method: 'POST'
}
}
);
});
var CreateCtrl = function($scope, $location, Revision) {
$scope.save = function() {
Revision.create($scope.revision);
$location.path('/revision-list');
};
};
然而它没有:)在网络标签中我遇到以下问题:方法不是post
而是options
,状态:load cancelled
并输入:{{1}那么为什么会这样,我该如何解决呢?
答案 0 :(得分:0)
如果您看到OPTION
而不是POST
,则可能意味着您遇到了跨源资源共享限制。您的浏览器阻止了XHR调用,因为您的服务器未配置为允许跨源(在不同域之间)调用。