Я хочу сохранить массив, используя ngStorage для постоянных потребностей в данных. Вот мой код:
.factory("items", function () {
var items = {};
items.data = [];
return items;
})
.controller('ItemsController', function($scope,items) {
$scope.items = items;
$scope.addItem = function (id,item,size,price,quantity) {
items.data.push({id,item,size,price,quantity});
}
})
Мне нужно сохранить массив элементов в ngStorage
.controller('ItemsController', function ($scope, items, $localStorage) {
$scope.items = items;
$scope.addItem = function (id, item, size, price, quantity) {
items.data.push({id, item, size, price, quantity});
localStorage.setItem("items", JSON.stringify(items));
}
});