单击按钮我正在调用方法Getdata();但问题是当页面第一次加载时,如果我点击按钮然后我得到" HTTP错误"响应。但如果我再次点击该按钮,则会显示成功响应。
HTML
<button type="submit" class="btn btn-primary form-inline inline-Magrin" ng-click="Getdata()">Search</button>
JS
$scope.Getdata = function () {
if (($scope.NumberOfrecords > $scope.TotalRecords) && ($scope.TotalRecords != 0)) {
alert("Search record count should not be greater than total records");
return;
}
debugger;
$http({
url: '/scrap/Resultdata',
method: "GET",
params: {
Searchbox: $scope.Searchbox,
Category: $scope.Category,
NumberOfrecords: $scope.NumberOfrecords
}
}).then(
function successCallback(response) {
response = $scope.filterRecord(response);
debugger;
$scope.data = response.data.ResponseItems;
$scope.TotalRecords = response.data.TotalResults;
$scope.tableParams = new NgTableParams({
page: 1,
count: 10
}, {
data: $scope.data
});
},
function errorCallback(response) {
debugger;
alert("error");
});
}
答案 0 :(得分:1)
按钮类型为“提交”,应为“按钮”
<button type="button" class="btn btn-primary form-inline inline-Magrin" ng-click="Getdata()">Search</button>
答案 1 :(得分:1)
如果您将提交作为类型,那么您需要在html中添加标签
并以表格形式-------- 的OnSubmit =的GetData()
请尝试使用type =按钮