AngularJS中文社区ajax返回的页面通过脚本设置的cookie,怎么破
1个回答
展开全部
angularjs中的ngCookie是可以设置cookie的过期日期的,示例代码如下:
angular.module('cookiesExample', ['ngCookies'])
.controller('ExampleController', ['$cookies', function($cookies) {
// Find tomorrow's date.
var expireDate = new Date();
expireDate.setDate(expireDate.getDate() + 1);
// Setting a cookie
$cookies.put('myFavorite', 'oatmeal', {'expires': expireDate});
}]);
angular.module('cookiesExample', ['ngCookies'])
.controller('ExampleController', ['$cookies', function($cookies) {
// Find tomorrow's date.
var expireDate = new Date();
expireDate.setDate(expireDate.getDate() + 1);
// Setting a cookie
$cookies.put('myFavorite', 'oatmeal', {'expires': expireDate});
}]);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询