$http 响应头消息

问题描述:

是否可以在 anulgarjs 中获取响应头消息?

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

在类似的代码中

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

在警报中,我需要写这样的东西:500内部服务器错误.在控制台日志中,我可以看到错误状态和文本消息,我必须在错误情况下放什么?最好的方法是什么?

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?

试试这个

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

查看此文档