Javascript 通过aspx网页中的Angularjs将数据传递给WebMethod

Javascript 通过aspx网页中的Angularjs将数据传递给WebMethod,javascript,c#,asp.net,angularjs,Javascript,C#,Asp.net,Angularjs,希望知道如何使用Angularjs将数据传递到aspx页面中的WebMethod,就像我们在jQuery中所做的那样 下面是我用来将数据加载到ui网格的代码,目前我只在页面加载时加载。我需要基于传递给webmethod的数据的按需信息 var myApp = angular.module('sampleapp', ['ui.grid', 'ui.grid.selection', 'ui.grid.exporter', 'ui.grid.resizeColumns']); myApp.co

希望知道如何使用
Angularjs
将数据传递到aspx页面中的
WebMethod
,就像我们在
jQuery
中所做的那样

下面是我用来将数据加载到ui网格的代码,目前我只在页面加载时加载。我需要基于传递给webmethod的数据的按需信息

var myApp = angular.module('sampleapp', ['ui.grid', 'ui.grid.selection', 'ui.grid.exporter', 'ui.grid.resizeColumns']);
    myApp.controller("appcontroller", function ($scope, $http) {
        $scope.gridOptions = {
            enableGridMenu: true,
            exporterMenuCsv: true,
            exporterMenuPdf: false,
            exporterCsvFilename: 'ExportExceptionFile.csv',

            data: 'BindDataTableusingJSON',
            columnDefs: [
            {
                field: 'FileID', displayName: 'File ID', width: '90'
            },
            {
                field: 'FileName', displayName: 'File Name', width: '180'
            }]
        };



    $scope.BindDataTableusingJSON = {
        "data": []
    };

    $http.post('WebForm1.aspx/GetUserData',
        {
            data:
            {}
        })           
    .success(function (data) {                   

        var d = JSON.parse(data.d);
        $scope.BindDataTableusingJSON = d;
    });
}).config(function ($httpProvider) {
    $httpProvider.defaults.headers.post = {};
    $httpProvider.defaults.headers.post["Content-Type"] = "application/json; charset=utf-8";
});  
aspx页面中的My
WebMethod

[WebMethod]
[ScriptMethod]
public static string GetUserData(string data) //wish to pass data here in 'string data'
{            
    return DataTableToJSONWithJavaScriptSerializer();
}

试着这样做:

$http.post('WebForm1.aspx/GetUserData',
                {
                    {data: 'data value'}
                })           
                .success(function (data) {                   

                    var d = JSON.parse(data.d);
                    $scope.BindDataTableusingJSON = d;
                });