<script>
var app = angular.module("myApp", []);
app.controller("myCntrl", function ($scope, $http) {
$scope.studentorder = "StudetnID";
$scope.studetnName = "";
$scope.Save = function () {
var httpreq = {
method: 'POST',
url: 'Default.aspx/Save',
headers: {
'Content-Type': 'application/json; charset=utf-8',
'dataType': 'json'
},
data: { StudentName: $scope.studetnName }
}
$http(httpreq).success(function (response) {
$scope.fillList();
alert("Saved successfully.");
})
};
$scope.Delete = function (SID) {
if (confirm("Are you sure want to delete?")) {
var httpreq = {
method: 'POST',
url: 'Default.aspx/Delete',
headers: {
'Content-Type': 'application/json; charset=utf-8',
'dataType': 'json'
},
data: { StudentID: SID }
}
$http(httpreq).success(function (response) {
$scope.fillList();
alert("Deleted successfully.");
})
}
};
$scope.fillList = function () {
$scope.studetnName = "";
var httpreq = {
method: 'POST',
url: 'Default.aspx/GetList',
headers: {
'Content-Type': 'application/json; charset=utf-8',
'dataType': 'json'
},
data: {}
}
$http(httpreq).success(function (response) {
$scope.StudentList = response.d;
})
};
$scope.fillList();
});
</script>