Ionic local storage

use JSON.stringify to set the item and JSON.parse when you get it, so replace:

window.localStorage.setItem('cart', cart);
// and
var cart = window.localStorage.getItem('cart');

by,

window.localStorage.setItem('cart', JSON.stringify(cart));
// and
var cart = JSON.parse(window.localStorage.getItem('cart'));
2 Likes