javascript - angularjs factory promises and couchDB -


please bare me still learning angularjs.

i have written following service data local json file:

healthsystemservice.factory('healthsystemdata', ['$resource', function($resource) {   return $resource('scripts/data/health-system/data.json', {}, {     get: {       method: 'get',       isarray: true     }   }); } ]); 

then use service in controllers:

$scope.healthsystems = healthsystemdata.get(); 

now, know how fetch same data pouchdb database:

var db = new pouchdb('healthsystems');  db.get('healthsystems_list').then(function(doc) {     return doc.list; }); 

as can see promise resolve .then

my problem when try replace hard coded data in factory

'scripts/data/health-system/data.json' 

with data couchdb. trying like:

healthsystemservice.factory('healthsystemdata', ['$resource', function($resource) {   return $resource(***data couchdb(a promise)***, {}, {     get: {       method: 'get',       isarray: true     }   }); } 

i not quite understand how use promises in services factory. please code?

thank much.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -