数组 – AngularJS将数组添加到cookie存储区
发布时间:2020-12-17 06:47:01 所属栏目:安全 来源:网络整理
导读:摘录如下 function CartForm($scope,$cookieStore) {$scope.invoice = { items: [{ qty: 10,description: 'item',cost: 9.95}]};//want to add the above array to cookie store here } 我如何将上面的数组放入cookiestore,然后访问它并绑定它? 解决方法 在
摘录如下
function CartForm($scope,$cookieStore) { $scope.invoice = { items: [{ qty: 10,description: 'item',cost: 9.95}] }; //want to add the above array to cookie store here } 我如何将上面的数组放入cookiestore,然后访问它并绑定它? 解决方法
在cookie中放入和获取数据的标准方法是:
Put:$cookieStore.put(‘invoice’,$scope.invoice); 获取:返回$cookieStore.get(‘invoice’); 这需要在您的应用中引用ngCookies,以及外部angular-cookies脚本.请参阅this plunk,查看登录控制台的cookie. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |