如何在AngularJS中使用ng-cookies?
请看这个例子:
angular.module('myAdminApp', [
'ngAnimate',
'ngCookies']).controller('navCtrl', function ($cookies) {
$cookies.put('logOff', 'success');
window.location = getBaseUrl() + 'Cpanel/Login';
});
并在登录页面中:
angular.module('myLoginApp', [
'ngAnimate',
'ngCookies']).controller('loginCtrl', function ($cookies) {
var r = $cookies.get('logOff');// always value is undefined
});
为什么r
是undefined
?