The snippet is as follows
function CartForm($scope,$cookieStore) {
$scope.invoice = {
items: [{
qty: 10,
description: 'item',
cost: 9.95}]
};
//want to add the above array to cookie store here
}
How can i put the above array into cookiestore, and later access it and bind it ?
The standard way to put and get data in cookies is this:
Put:$cookieStore.put('invoice', $scope.invoice)
;
Get: return $cookieStore.get('invoice')
;
This will require a refrence to ngCookies in your app, and also the external angular-cookies script. See this plunk, see the cookie getting logged in the console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With