angularjs中做了根据条件查询的方法,并实现了分页查询的功能,但是,点击查询后,页面会首先调用查询方法,然后再将条件情况后重新加载这是什么问题,代码如下:
app.controller('QuestionCtrl', function ($scope, $http, $timeout) {
$scope.paginationConf = {
currentPage: 1,
itemsPerPage: 10,
pagesLength: 10,
perPageOptions: [10, 20, 30, 40, 50],
onChange: function () {
$scope.Query();
}
};
$scope.Query = function () {
var url = "ashx/Question.ashx";
$scope.QueryModel = { Subject: $scope.Subject, Category: $scope.Parent == undefined ? 0 : $scope.Parent.ID
, AppraiseType: $scope.AppraiseType == undefined ? 0 : $scope.AppraiseType.Code
};
$http.get(url, { params: { Type: "Query", QueryModel: $scope.QueryModel
, startIndex: $scope.paginationConf.currentPage != 1 ? ($scope.paginationConf.currentPage - 1) * $scope.paginationConf.itemsPerPage + 1 : $scope.paginationConf.currentPage
, endIndex: $scope.paginationConf.currentPage * $scope.paginationConf.itemsPerPage
}
}).success(function (response) {
$scope.Parents = response.Parents;
$scope.Parent = response.Parents[0];
$scope.AppraiseTypes = response.AppraiseTypes;
$scope.AppraiseType = response.AppraiseTypes[0];
//数据源
$scope.paginationConf.totalItems = response.Count.length; //总数
$scope.Questions = response.Questions;
})
相关分类