I am developing an Ionic Framework app. Also, I am using $cookieStore
to store some array data. My array data gets stored in the $cookieStore
unless the route changes.
Whenever I go back to the previous page the cookies get cleared.
This is what I have tried:
$scope.invoice = {
items: [{
id: 1,
qty: 10,
description: 'sample',
cost: 99
}]
};
$scope.addItem = function() {
$scope.invoice.items.push({
id: $stateParams.foodId,
qty: $scope.count,
description: $scope.ar_name,
cost: $scope.total
});
$cookieStore.put("invoices",$scope.invoice.items);
console.log( $cookieStore.get("invoices",$scope.invoices));
//var favoriteCookie = $cookies.get('invoices');
$scope.lastVal = $cookieStore.get('invoices');
};
Looks like $cookieStore is deprecated. Have you tried using $cookies https://docs.angularjs.org/api/ngCookies/service/$cookies?
Are you able to set the path? I think cookies by default are set only for the current page rather than a root domain level. That may be why you're only seeing them on the first page?
If you try and use $cookies with the $cookiesProvider https://docs.angularjs.org/api/ngCookies/provider/$cookiesProvider and set the path to '/'