我在.net中創建了一個RESTful API。html是使用angularJS創建的。AngularJS Post方法獲取錯誤
和「插入」按鈕不起作用了。
這是我的插入腳本和HTML全文可以在鏈接中找到:
$scope.insert = function insert() {
var data = {"id": 3, "name": $scope.name, "description":$scope.description , "price": $scope.price, "categoryid": $scope.categoryid};
$http.post(
'http://localhost:22258/api/product',
JSON.stringify(data),
{
headers: {
'Content-Type': 'application/json'
}
}
).success(function (data) {
$scope.products.push(data);
});
https://jsfiddle.net/0xb2nh9o/
即使你是友善幫我做編輯鍵設置爲以下模型:https://jsfiddle.net/benfosterdev/UWLFJ/使HTTPPut成爲API,這將是美好的。
所有RESTful請求工作,API的工作,與郵遞員
測試我金達新手到AngularJS所以你的幫助將是我非常有用的。非常感謝 !
插入操作現在可以工作,但是在完成插入之後如何實現表格自動更新? – TrulyXax
你有一堆調用'localhost',所以不能從jsfiddle測試 –
我有angular.js:10071TypeError:無法讀取GetTemplate函數 – TrulyXax