i am creating android application using ionic and angularjs and using window.requestFileSystem for get image from storage. So for this process i used $q.defer() for asynchronous process and its working fine and showing object in console: console.log(deferred.promise)

but now, when i am trying to get the value from deferred.promise like
var vals = deferred.promise;
console.log(vals.$$state.value);
its showing undefined. Can anyone tell me how i can get that value?
My Code:
var deferred = $q.defer();
document.addEventListener("deviceready", function() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
imagePath = fileSystem.root.toURL() + 'SmaartMedia/' + splited[splitedLength-1];
deferred.resolve(imagePath);
$rootScope.$apply();
});
}, false);
var vals = deferred.promise;
console.log(vals.$$state.value);
Thanks
function getStuff() {
var deferred = $q.defer();
document.addEventListener("deviceready", function () {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
imagePath = fileSystem.root.toURL() + 'SmaartMedia/' + splited[splitedLength - 1];
deferred.resolve(imagePath);
$rootScope.$apply();
});
}, false);
return deferred.promise;
}
//Get value like this
getStuff().then(function(response){
//Use value here
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With