angular-phonegap
angular-phonegap copied to clipboard
Promises
This will be much better to use promises in your library.
And instead of:
function success(fileUrl) {
console.log('success: %s', fileUrl);
mySuperCoolService(fileUrl).then(...);
}
function err(reason) {
console.log('failed: %s', reason);
}
camera.takePicture(success, err);
user may use this:
camera.takePicture()
.then(function (fileUri) {
return mySuperCoolService(fileUrl)
}, function (reason) {
return $q.reject(reason);
})
.then(function (result) {
return result; // some result processing...
})
;
This is also solves issue that user should manually call $apply as you should do it from services.