0
角度サービスを使用してデータベースからレコードを削除しようとしています。私は私のMVCコントローラでメソッドを作成しましたが、このメソッドを呼び出してidを渡す方法はわかりません。データベースから角度を削除する
[HttpPost] public static void DeleteRecord(int settingID) { try { using (SqlConnection conn = new SqlConnection(connStringApps)) { conn.Open(); using (SqlCommand command = new SqlCommand("DeleteCurrentRecord", conn)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add("@SettingId", SqlDbType.VarChar).Value = settingID; command.ExecuteNonQuery(); command.Parameters.Clear(); } conn.Close(); } } catch (Exception ex) { Console.Write(ex.ToString()); } } myApp.service("deleteService", function ($rootScope) { this.removeRow = function (recId) { } }); myApp.controller('myController', ['$scope','deleteService', function ($scope, deleteService) { $scope.deleteRecordFromDB = function (recId) { //record id is the Id of the record that I want to delete } ; } ]);
ありがとうございます。私はコントローラにサービスを追加するときに何か他のことをする必要がありますか?サーバー側のhttpGetでアクセスする方法を教えてください。 – user6440175
はい。 $ scope.deleteRecordFromDB = function(recId){ deleteService.removeRow(recId);サービスメソッドを呼び出す必要があります。 } ; – rahulbhondave
ありがとうございます。 $ httpが定義されていないというエラーが表示されます。 – user6440175