我使用REST API,我想用PUT請求更新我的項目對象。該請求在API中受支持,並且我試圖使用$ resource來放置數據,但它似乎不起作用。這是我做的:
var projectResource = $resource('/api/projects/' + projectId, {update: {method: "PUT"}});
$scope.editProject = function(editedProject) {
projectResource.$update(editedProject);
}
其中editedProject是具有新值的項目,由網頁中的表單填充。我知道我的projectResource聲明中有錯誤,但我沒有找到。幫幫我 !
[Angular $ resource update method not found]的可能重複(http://stackoverflow.com/questions/14286713/angular-resource-update-method-not-found) – Stewie
什麼是錯誤? – Narretz
在聲明資源時,您需要傳遞另一個參數(第二位)作爲'{}'。 – Chandermani