我已经写上按钮onClick
从服务器将数据,但它不带我去这是写在服务器端GetMPFilter
功能
$scope.GetFilter = function () {
var strZone = $('#SAPExecutive_R4GState').val();
var strUtility = $('#ddlUtility').val();
$scope.dtColumns = [
DTColumnBuilder.newColumn(null, '').renderWith(function (data, type, full) {
return '<input type="checkbox" class="check" data-object-id="' + full.objectid + '">'
}),
DTColumnBuilder.newColumn("MAINTENANCEZONENAME", "MAINTENANCEZONENAME"),
DTColumnBuilder.newColumn("MAINTENANCEZONECODE", "MAINTENANCEZONECODE")
]
$scope.dtOptions = DTOptionsBuilder.newOptions().withOption('ajax', {
method: "POST",
url: AppConfig.PrefixURL + "/App/GetMPFilter",
dataType: 'json',
data: JSON.stringify({ strZone: strZone, strUtility: strUtility }),
headers: { "Content-Type": "application/json" }
})
.withPaginationType('full_numbers')
.withDisplayLength(10);
}
});
Server code
[HttpPost]
public JsonResult GetMPFilter(string strZone, string strUtility)
{
DataTable dt = new DataTable();
Filters ObjFilter = new Filters();
dt = ObjFilter.GetMPFromState(strZone, strUtility);
var MpList = (from DataRow dr in dt.Rows
select new
{
//Action = "",
MZONENAME = Convert.ToString(dr["MAINTENANCEZONENAME"]),
MZONECODE = Convert.ToString(dr["MAINTENANCEZONECODE"]),
}).ToList();
return Json(MpList, JsonRequestBehavior.AllowGet);
}
<button class="btn btn-default customBtn" ng-click="GetFilter();"><i class="fa fa-filter" aria-hidden="true"></i> Filter</button>
请建议我在哪里错了
请使用这些变化我张贴。我希望这将解决您的问题。谢谢。
$scope.GetFilter = function () {
var strZone = $('#SAPExecutive_R4GState').val();
var strUtility = $('#ddlUtility').val();
$scope.dtColumns = [
DTColumnBuilder.newColumn(null, '').renderWith(function (data, type, full) {
return '<input type="checkbox" class="check" data-object-id="' + full.objectid + '">'
}),
DTColumnBuilder.newColumn("MAINTENANCEZONENAME", "MAINTENANCEZONENAME"),
DTColumnBuilder.newColumn("MAINTENANCEZONECODE", "MAINTENANCEZONECODE")
]
$scope.dtOptions = DTOptionsBuilder.newOptions().withOption('ajax', {
method: "POST",
url: AppConfig.PrefixURL + "/App/GetMPFilter",
dataType: 'json',
data: "{strZone:'" + strZone + "',strUtility:'" + strUtility + "'}",
headers: { "Content-Type": "application/json; charset=utf-8" }
})
.withPaginationType('full_numbers')
.withDisplayLength(10);
}
});
这里是按钮点击的简单的例子:
<body ng-controller="MainCtrl">
<p>Hello {{name}}!</p>
{{msg}}
<a ng-href='#here' ng-click='go()' >click me</a>
<div style='height:1000px'>
<a id='here'></a>
</div>
<h1>here</h1>
</body>
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
$scope.go = function() {
$scope.msg = 'clicked';
}
});