【发布时间】:2014-04-23 15:14:29
【问题描述】:
sn-p如下
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中,然后访问它并绑定它?
【问题讨论】:
-
Put:
$cookieStore.put('invoice', $scope.invoice);Get:return $cookieStore.get('invoice'); -
你好@MohammadSepahvand 是的,我试过了。检查这个 JSFiddle jsfiddle.net/slav123/75m7e/3 。代码是从中获取的。当我将 $cookieStore 添加到 CartForm 时,它停止运行。我尝试添加 angular cookie 的外部资源,它仍然没有工作。
-
看我的回答,它有一个工作的plunk。
-
是的,它现在工作正常。只需将其放在本地主机上。非常感谢:)