angularJS读取cookie的响应值 [英] angularJS cookie read response value
本文介绍了angularJS读取cookie的响应值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我提出的要求,我的服务器上有$ HTTP我的的followig响应:
if i made a request on my server with $http i the the followig response:
Request URL:http://www.test.tst/login
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:application/json, text/plain, */*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Cookie:JSESSIONID=349AD3AC797C6AB28121ADA1766FF4A2
Host:www.test.tst
我怎么能宣读了曲奇:JSESSIONID = 349AD3AC797C6AB28121ADA1766FF4A2?
how can i read out the "Cookie:JSESSIONID=349AD3AC797C6AB28121ADA1766FF4A2"?
感谢
推荐答案
您可以使用 ngCookies 。为了做到这一点,你需要包括你的模块中的角cookies.js和ngCookie。
You can use ngCookies. In order to do it, you need to include the angular-cookies.js and the ngCookie in your module.
然后你可以注入$饼干和通过其get函数得到的cookie
Then you can inject $cookies and get the cookie via its get function
<script src="angular-cookies.js">
和,在你的js
angular.module('app', ['ngCookies']).controller('Test', ['$cookies', '$scope',
function($cookies, $scope) {
$scope.value = $cookies.get('JSESSIONID');
}
]);
这篇关于angularJS读取cookie的响应值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文