This is WebMethod in aspx page
[WebMethod]
public static string method(string name)
{
return name;
}
This is angularcode
var app = angular.module('app', []);
app.controller('myController', function ($scope, $http) {
$scope.ButtonClick = function () {
var post = $http({
method: "POST",
url: "WebForm1.aspx/method",
dataType: 'json',
data: { name: 'name' },
headers: { "Content-Type": "application/json" }
}).then(function (data) {
$scope.name = data.data.d;
alert($scope.name);
});
}
$scope.ButtonClick();
});
No comments:
Post a Comment