0

I am trying to pass data between two pages which are having Angular controllers.

Now I came across 2 different ways to pass data:

  1. via Angular service (similar to here)
  2. using HTML5 storage option (either Local/Session as shown here)

From development perspective I wanted to know as which is more preferred method of passing data? Can this scenario change if we are dealing with large JSON data ?

Community
  • 1
  • 1
BlueSword
  • 1,290
  • 12
  • 25
  • each strategy is viable, with pros and cons to both. In general, you use a service when you are using the data within the current usage session of the app, and storage when you need to save data for use in future sessions. – Claies Oct 19 '16 at 18:02

1 Answers1

0

This answer - Ionic local storage vs using service - gives a good summary of the differences: local storage should be used primarily for data that will be used across a number of sessions or persists for a long time, whereas data in an Angular service is tied to that page.

Community
  • 1
  • 1
  • The answer I linked to refers to Ionic local storage - refer to this https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage one for details about HTML5 local stores. Same principle. – Mitch Vogel Oct 19 '16 at 18:07