Angular.js RESTful API with fallback to PouchDB when offline