2013-12-18 2 views
1

간단한 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입니다. POST 요청시 $http POST 요청에 URL 행에 매개 변수가 없으므로 데이터가 요청 본문에있는 것 같습니다.

답변

1

다른 웹 사이트의 누군가가 친절하게 도와주었습니다. 다른 사람들에게 도움이 될 수 있기를 희망합니다.

Restangular.all('lifts').post($scope.Lift).then(function (newLift) { 
     $scope.getLifts(); 
    }, function (error) { 
     console.log(error); 
    }); 

추가 'lift' 인수

post 호출에 필요하지 않았다.