【发布时间】:2013-12-18 00:27:09
【问题描述】:
我有一个简单的 ASP.NET Web API 2 服务。我是 Angular 的新手,但我正在尝试从使用 $http 切换到 Restangular。我的 GET 似乎很好,但我的 POST 不是。
代码如下:
$scope.addLift = function () {
$http.post(url, $scope.Lift);
//Restangular.all('lifts').post('Lift', $scope.Lift).then(function (newLift) {
// $scope.getLifts();
//}, function (error) {
// console.log(error);
//});
};
注释掉的 Restangular 代码不起作用,但 $http.post 起作用,我不确定自己做错了什么。
如果有帮助的话,使用 Restangular 时的 POST 是 http://localhost/api/lifts?LiftName=test 在 $http POST 请求中,它不包含 URL 行上的参数,似乎数据在请求正文中。
【问题讨论】:
标签: angularjs restangular