angularJS cookie read response value

前端 未结 2 1952
一个人的身影
一个人的身影 2021-01-06 06:38

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          


        
相关标签:
2条回答
  • 2021-01-06 07:09

    You can use ngCookies. In order to do it, you need to include the angular-cookies.js and the ngCookie in your module.

    Then you can inject $cookies and get the cookie via its get function

    <script src="angular-cookies.js">
    

    And, in your Js

    angular.module('app', ['ngCookies']).controller('Test', ['$cookies', '$scope', 
        function($cookies, $scope) {
            $scope.value = $cookies.get('JSESSIONID');
        }
    ]);
    
    0 讨论(0)
  • 2021-01-06 07:20

    $cookies does provide the .get function that is $cookieScope

    If using $cookies you should just use $cookies.JSESSIONID

    Angular $cookies

    and

    Angular $cookieStore

    0 讨论(0)
提交回复
热议问题