0

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...

2
  • What do you mean exactly? How to check which type the response is? Eg. if ( typeof check === 'object' ) { /* do something */ }? Commented Dec 9, 2015 at 8:46
  • check is object but I want change check=$scope.checkActDate() to the data.reponseVo's value in function Commented Dec 9, 2015 at 8:48

1 Answer 1

2

$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
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.