我是AngularJs的新成员,我的问题是:
$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;
}
目前,我得到的return data.responseVo
是一个String "0"
,我知道$scope.checkActDate
是一个物体,但我不知道,我的问题是return data.responseVo
和var check
如何获得字符串"0"?
非常感谢。。。
$http
请求是一个异步请求,因此与其在成功时返回数据,不如将其存储在范围变量中。像
remoteService.success(function(data, status, headers, config) {
$scope.data = data.responseVo;
})
现在您可以对$scope.data
进行检查
if($scope.data != "0"){
// Do your stuff here
}