After creating a service to retrieve data from a local json file, I proceeded to integrate this service with my controllers. However, I recently discovered how to fetch the same data from a pouchDB database.
$scope.healthSystems = HealthSystemData.get();
The next challenge I faced was replacing the hardcoded data path in my factory with the dynamic data from the couchDB. This involved working with promises within the service factory, a concept that I was not very familiar with.
healthSystemService.factory('HealthSystemData', ['$resource',
function($resource) {
return $resource(***DATA FROM THE COUCHDB(a promise)***, {}, {
get: {
method: 'GET',
isArray: true
}
});
}
If anyone could offer guidance or provide some sample code on how to effectively utilize promises in services factories, it would be greatly appreciated.