如何在AngularJS中使用ng-cookies?

时间:2015-08-29 02:17:08

标签: angularjs cookies

如何在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
});

为什么rundefined

0 个答案:

没有答案