311376 (1) [Avatar] Offline
Hi, I am totally clueless on how to persist any changes to localStorage.

jeremy.wilken (208) [Avatar] Offline
Chapter 7 actually implements persistence for the chapter 6 example, but the same rules will apply. It will be a couple weeks before chapter 7 is updated on the MEAP, but I'll give you some tips.

First, you'll want to store data into local storage. For chapter 5, the persistence is based on the Currencies service. Anytime the Currencies are changed (reordered or toggled) you would want to store the Currencies values into local storage doing something like this.

localStorage.setItem('currencies', angular.toJson(Currencies));

Secondly, you'll need to have the app try to load from local storage when the app loads to reload any stored data (if it exists). localStorage.getItem('currencies') will return either the stored JSON string, or null if nothing exists. You'll have to parse the JSON if it exists, or return the default settings.

If you aren't familiar with local storage, check out this article http://www.smashingmagazine.com/2010/10/11/local-storage-and-how-to-use-it/. Local storage works in our hybrid apps the same as it does for a traditional website, so even though this article doesn't talk about mobile apps the same rules apply.
Jose Luis Uribe (6) [Avatar] Offline
Hi Jeremy,

I am implementing a photo album, where I can upload photos from local storage, FB or Instagram to the cloud for example uploadcare.com and keep a local copy in the device local storage. Could you recommend an Image Cache approach or a persistence file using cordova-plugin-file? And Is there a pluging to cache/save Images on the device ?

Thank you!

jeremy.wilken (208) [Avatar] Offline
Sorry about the delay.

I haven't tried to do this, so I can't speak with much authority here. You might want to check out the Cordova in Action book and talk with Raymond.

I did see this for iOS, which might be the approach you'd want to take.


Jose Luis Uribe (6) [Avatar] Offline

I finally could setup SaaS to upload photos, that is uploadcare.com and it is working fine with ionic.

You could find some screens in this url: