In my angular2 app i have list of products, customers, etc which are fetched from RESTful web service. The lists are widely used throughout the app in various components. Every time they are used in a component, they are fetched from web service. I want to fetch them when the app loads for the first time and cache them so that where ever i want to use them i use the cached lists and not fetching from web service every time. How to achieve this functionality? Also i want to invalidate the cached objects if a new item is updated, added or removed.
Asked
Active
Viewed 268 times
1
-
Try storing it in an array in $rootScope.yourList – driconmax Nov 25 '16 at 14:34
-
1http://stackoverflow.com/questions/36271899/what-is-the-correct-way-to-share-the-result-of-an-angular-2-http-network-call-in – Günter Zöchbauer Nov 25 '16 at 14:42