Reputation: 9
I'm a new enter of AngularJs, and my question like this:
$scope.checkActDate = function(){
var remoteService =$http({
method : 'POST'
url : "../checkActDateChm803.action",
data: {actDate:$scope.ch803FVo.actDate},
dataType: "json",
headers:{'Accept': 'application/json', 'Content-Type':'application/json; ; charset=UTF-8'}
});
remoteService.success(function(data, status, headers, config) {
return data.responseVo;
})
};
var check = $scope.checkActDate();
if(check != "0"){
return true;
}
For now, I got the return data.responseVo
is a String "0"
,
and I know the $scope.checkActDate
is a object, but I have no idea and my question is
how could I return data.responseVo
and var check
can get String "0" ?
thanks a lot...
Upvotes: 0
Views: 62
Reputation: 13228
$http
request is an asynchronous request, so rather than returning data on success you should store it inside scope variable. Like
remoteService.success(function(data, status, headers, config) {
$scope.data = data.responseVo;
})
Now you can perform a check on $scope.data
if($scope.data != "0"){
// Do your stuff here
}
Upvotes: 2