在Angular JS ui路由器中获取接收到的Http标头

问题描述 投票:0回答:1

我是Angular的新手。我有以下Angular JS(v.1.7)ui-router

.state('helpPage', {
    url: "/help",
    data: {
        roles: []
    },
    views: {
        helpDoc: {
            templateUrl: 'app/modules/help/help.tpl.html',
            controller: 'helpCtrl'
        }
    }
})

[当用户点击此页面时,我要检索标题。我可以在Controller或ui-route的resolve方法本身中获取它们吗?

尝试过HttpInterceptor,但没有帮助。

非常感谢您的帮助。

angularjs angular-ui-router http-headers
1个回答
0
投票

使用$ http headers对象的response属性:

$http.head(url).then(function(response) {
     var headerGetter = response.headers;
     console.log(headerGetter("headerName"));
});

有关更多信息,请参阅

© www.soinside.com 2019 - 2024. All rights reserved.