reference angular-cookies.min.js
var app= angular.module( ‘app‘, [‘ngCookies‘] ).config( demoConfig );
$cookie
$cookieStore
$cookieStore.put("name","my name"); $cookieStore.get("name") == "my name"; $cookieStore.remove("name"); $cookieStore.put("persion", { name: "my name", age: 18 }); scope.person = $cookieStore.get("persion");//会使用angularjs 的 toJson/fromJson 自动序列化和反序列化 app.controller(‘DemoController‘, function ($cookies, $scope) { $cookies.myFavorite = ‘oatmeal haha‘; })
时间: 2024-11-29 11:34:02