A
A
amf1k2015-05-23 11:42:25
Angular
amf1k, 2015-05-23 11:42:25

How to make a data storage service in Angular?

I want to make a service for storing objects so that you can add, delete and receive these objects. Didn't find an example. Maybe someone has an example?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Tartmin, 2015-05-25
@baskerville42

Mmm... LocalStorage || SessionStorage?

S
Stepan Kormilin, 2015-11-12
@Stepan13

That is, if I receive some data from the server, with which I then have to work in different variations, then in order not to load this data from the server each time, can I use only localstorage?
For example, I have two lists that depend on one another (industry and category, several categories can belong to one industry). Initially, I receive json with an array of two objects: 1. industries 2. categories (each has a property - which industry it belongs to)
Further, for example, if I choose an industry, then only those that belong to this industry should remain in the list of categories. That is, I get the id of the industry and run through the array of categories, check if there is a binding to the industry, then I put the category in the $scope.tmpArray array is valid. Next $scope.category = $scope.tmpArray;
This leads to the result that is needed, the categories are updated in the list, the extra ones are filtered. And in this case, I must first save $scope.category somehow (in localstorage?), Or at the next choice, request the full data from the server again in order to perform the entire filtering procedure. I don't understand how to do it right.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question