There is a typo in the promise , it should be new Promise . Although I would suggest you use $q instead of promise .
The advantage of using $q instead of the promise object is that the code will be an angular context, and you do not have to worry about starting the digest cycle manually. Where, as if you were using promise , you need to start the digest cycle manually (since promise will be a built-in asynchronous JS function, considered the outside world of angular).
createDirectory: function(directoryName, dirLocation) { var makePromise = $q(function(resolve, reject) { dirLocation.getDirectory(directoryName, { create: true, exclusive: false }, function(data) { resolve(data); }, function(error) { reject(error); }); }); return makePromise; };
Update
.fail function is not available in the $q object, you need to change the code of the fileManager.createDirectory function below.
$scope.createDirectory = function(dirName,dirLocation){ fileManager.createDirectory(dirName,dirLocation) .then(function(data){
source share