嗨,我是angularjs的新手。在我的要求中我得到了确切的数据,但点击不是第二次工作。我尝试了很多方法,但没有工作。请提前感谢解决我的问题
$scope.click = function () {
alert("hi");
$scope.selected = "";
var x = $('#txtSearch').val();
var _ReqObj = new Object();
_ReqObj.id = x;
_ReqObj.Meth = "CD";
// alert(x);
var httpreq = $http({
method: 'POST',
url: "../Harneedi2/api/Home",
data: _ReqObj
}).success(function (response) {
if (response == '') {
alert('no data');
}
else {
$scope.click = response;
alert("data");
}
});
<button class="btn btn-default" id="click" runat="server" type="submit" ng-click="click()"><i class="fa fa-search" style="color:brown;"></i></button>
答案 0 :(得分:2)
在其他模块中,您将responce
分配给$scop.click
变量,点击就是您的功能
这是您的代码的问题尝试此代码可能会帮助您
$scope.responce = {};
$scope.click = function () {
alert("hi");
$scope.selected = "";
var x = $('#txtSearch').val();
var _ReqObj = new Object();
_ReqObj.id = x;
_ReqObj.Meth = "CD";
// alert(x);
var httpreq = $http({
method: 'POST',
url: "../Harneedi2/api/Home",
data: _ReqObj
}).success(function (response) {
if (response == '') {
alert('no data');
}
else {
//$scope.click = response;
$scope.responce = response;
alert("data");
}
});
<button class="btn btn-default" id="click" runat="server" type="submit" ng-click="click()"><i class="fa fa-search" style="color:brown;"></i></button>
你指定的是对你的错误点击功能的回应。