Offline data management


#1

Hello,

One of the aspects that sets mobile applications aside from web applications is their offline availability.
This requires a couple of things:
-A small portion of the database should be cached on the device
-When a user makes changes, they should be synced when the device gets back online.

Knowing we mainly talk to REST API’s, does ionic provide any facilities towards this offline data management or what are the best practices for this?

Thanks,
Seba


#2

Ionic is just the UI framework. It’s completely unrelated to data storage. In my app, I use ngStorage for storing some local data. It’s easy to use and works great if you are dealing with small pieces of data (current user, settings, etc).

If you’re dealing with lots of data and you need complex queries, synchronization and more, I suggest looking into PouchDB, and especially into its Replication feature. Replication allows you to sync data between the client-side database and the server-side database automatically.


#3

UPDATE : NEVER MIND ! : The problem was mine. It was completely unrelated to ngStorage.

@alon_gubkin Do you have any trouble with ngStorage on actual devices? Including it as a dependency works great in Chrome. However, once I build the app, it dies on iOS and throws an error in AngularJS.

Function required as first argument! angular.js:9435
(anonymous function) angular.js:9435
(anonymous function) angular.js:6846
Scope.$apply angular.js:12079
(anonymous function) angular.js:1302
invoke angular.js:3710
doBootstrap angular.js:1300
bootstrap angular.js:1314
angularInit angular.js:1263
(anonymous function) angular.js:20793
trigger angular.js:2345
(anonymous function) angular.js:2616
forEach angular.js:310
eventHandler angular.js:2615

How are you using it? Here’s where I inject it.

angular.module('kit', ['ionic', 'kit.services', 'kit.controllers', 'kit.directives', 'pasvaz.bindonce', 'ngStorage'])

FYI : I know that ngStorage is the problem because when I remove it, I don’t get the error.


ngStorage/local storage question...again