2013-06-13 3 views
4

REST API를 사용하고 PUT 요청으로 프로젝트 개체를 업데이트하고 싶습니다. 요청은 API에서 지원되며 데이터를 PUT하기 위해 $ resource을 사용하려하지만 작동하지 않습니다. 여기에 내가 할 것입니다 : editedProject 웹 페이지에서 양식에 의해 작성 새로운 값으로 프로젝트이다

var projectResource = $resource('/api/projects/' + projectId, {update: {method: "PUT"}}); 
    $scope.editProject = function(editedProject) { 
     projectResource.$update(editedProject); 
    } 

. 내 projectResource 선언에 잘못된 것이 있다는 것을 알고 있지만 무엇을 찾지 못했습니다. 도와주세요!

+0

[Angular $ resource update method not found] (http://stackoverflow.com)의 중복이 가능합니다./questions/14286713/angular-resource-update-method-not-found) – Stewie

+0

무엇이 오류입니까? – Narretz

+0

리소스를 선언하는 동안 다른 (두 번째 자리에) 인수를'{} '로 전달해야합니다. – Chandermani

답변

14

이 시도 :

$resource('/api/projects', { id: projectId }, { 
    update: { method: 'PUT' } 
}); 
0

$ 자원이 없음 '액세스 제어 - 허용 - 기원'의 사촌, 'PUT'방법을 만들 수 없습니다. 이 경우에는 PUT 호출을 만들어야합니다.

var data = $resource('someURL', { jobId: '@jobId'}, { 'update': { method:'PUT' }}); 
data.update(objectYouWannaUpdate); 
관련 문제