我正在尝试发布一个帖子,但是下面的内容似乎不起作用,它不能发布,但是console.log()看起来像一个put请求。
http://127.0.0.1/api/v1/participant?account=%7B%22pk%22:1%7D&email=someemail@gmail.com工厂
app.factory('CbgenRestangular', function(Restangular) {
return Restangular.withConfig(function(RestangularConfigurer) {
RestangularConfigurer.setBaseUrl('http://127.0.0.1');
});
});控制器
$scope.participant = {email :$scope.email, password: "", account:{pk:1}};
CbgenRestangular.all('api/v1/participant').post("participant", $scope.participant);我做错什么了?
发布于 2013-11-24 21:08:48
根据文档(https://github.com/mgonto/restangular#lets-code):
// First way of creating a Restangular object. Just saying the base URL
var baseAccounts = Restangular.all('accounts');
var newAccount = {name: "Gonto's account"};
// POST /accounts
baseAccounts.post(newAccount);注意,post只有一个输入
您可以将'api/v1‘添加到您的基本地址--无需携带它(https://github.com/mgonto/restangular#setbaseurl)
我还建议使用复数形式的资源路线,但这是一个惯例,有些人不遵循-我想这是一个品味的问题
https://stackoverflow.com/questions/20180880
复制相似问题