문제

is it possible in anulgarjs to fetch the response header message?

in a code similar to that

$http.get(url)
    .success(){
         something
    }.error(status,"headers text message)"{
             alert(status+" "+"headers text message or a method to get it";
    }

in the alert i need to write somthing like that: 500 internal server error. In the console log i can see the error status and text message, what do i have to put in the error case? what is the best way to do that?

도움이 되었습니까?

해결책

try this

$http.get(url)
    .then(function(response) {
  var data = response.data;
  var status = response.status;
  alert(status);
});

See this document

다른 팁

Of course you can! On success (or error) you have a callback with this parameters

$http({
url: 'url',
method: 'GET'
}).success(function(data, status, headers, config){
});

Check the documentation http://docs.angularjs.org/api/ng/service/$http

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top