<!DOCTYPE html>
<html ng-controller="cookies_controller">
<head>
<title>cookies.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div ng-click="init()">设置</div>
<div ng-click="get()">获取</div>
<div ng-click="remove()">移除</div>
</body>
<script type="text/javascript" src="../plugins/angular/angular.js"></script>
<script type="text/javascript"
src="../plugins/angular/angular-cookies.min.js"></script>
<script>
var cookies = angular.module("cookies", [ 'ngCookies' ]);
cookies.controller("cookies_controller", function($scope, $cookieStore) {
//设置和读取
$scope.init = function() {
alert(new Date(new Date().getTime()));
$cookieStore.put("book", {page : "120",price : 23});
};
$scope.get=function(){
alert(angular.toJson($cookieStore.get("book")));
};
$scope.remove=function(){
$cookieStore.remove('book');
};
});
angular.bootstrap(document, [ 'cookies' ]);
</script>
</html>