Angular在ajax$scope中返回String



我是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.responseVovar check如何获得字符串"0"?

非常感谢。。。

$http请求是一个异步请求,因此与其在成功时返回数据,不如将其存储在范围变量中。像

remoteService.success(function(data, status, headers, config) {    
    $scope.data = data.responseVo;
})

现在您可以对$scope.data 进行检查

if($scope.data != "0"){
    // Do your stuff here
}

最新更新