我剛開始學習angularjs,但我堅持保存記錄。我有一個帶有文本框的表單,用於輸入預填充選定記錄的數據的state,companyId和rate。當我點擊保存按鈕時,我會收到「POST〜/ AppWeb/AppApi/UpdateRecord 404(Not Found)」。我正在使用Oracle數據庫。我有以下代碼:嘗試更新記錄時發生AngularJS錯誤
的.js:
.factory("Services", function (Api) {
this.saveRecord = function (data) {
if (data.Id > 0) {
return Api.save("AppApi/UpdateRecord", data);
}
};
return this;
})
.controller("ViewSaveController", function ($scope, $routeParams, $location, State, Services) {
Services.getRecord($routeParams.id).success(function (d) {
$scope.model = d;
});
$scope.save = function (controller) {
Services.saveRecord($scope.model).success(function (d, s, h, c) {
//redirect to the list view
});
};
})
ApiControllder.cs:
public WorkRates UpdateRecord()
{
try
{
var q = new DemoQueries();
return q.UpdateRecord();
}
catch (Exception ex)
{
return null;
}
}
PartialQueries.cs:
public WorkRates UpdateRecord(int id, string state, string companyId, string rate)
{
var sql = "update ratestable set state = :state, companyId= :companyId, rate = :rate where id = :id";
var db = Db.Load(sql);
db.AddParameter(":id", id);
db.AddParameter(":state", state);
db.AddParameter(":companyId", companyId);
db.AddParameter(":rate", rate);
db.DoExecute();
var l = db.GetList<WorkRates>().FirstOrDefault();
return l;
}
我不知道爲什麼我得到此錯誤消息。任何幫助表示讚賞。
是的,仍然收到錯誤。 – Kate
它改變後它工作「Api/AppApi/UpdateRecord」 – Kate