我不明白爲什麼我無法獲取我的cookie?無法獲取cookie值
$ rootScopt.globals.currentUser =未定義
angular.module('MyModule', [
'Authentication',
'Home',
'ngRoute',
'ngCookies'
])
.config([
//Config
])
.run([
'$rootScope', '$location', '$cookies', '$http',
function($rootScope, $location, $cookies, $http) {
//Keep user logged in after page refresh
$rootScope.globals = {
currentUser: {
username: "foo",
password: "bar"
}
}
$cookies.put('globals', $rootScope.globals);
$rootScope.globals = $cookies.get('globals') || {};
if ($rootScope.globals.currentUser) { //Never go in here..
//Do stuff
}
}
]);
我檢查了,我的cookie獲取存儲,它似乎很好地工作。但是,當試圖讓我的cookie不起作用。任何人現在爲什麼?
是U使用的是什麼瀏覽器? – vivid