Created
September 11, 2014 12:08
-
-
Save partageit/34b897738edb4695c890 to your computer and use it in GitHub Desktop.
Partage-it.com : le contrôleur de suppression de fichiers pour blueimp-file-upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('testBlueimpApp') | |
.controller('FileDestroyCtrl', function ($scope, $http) { | |
var file = $scope.file, | |
state; | |
if (file.url) { | |
file.$state = function () { | |
return state; | |
}; | |
file.$destroy = function () { | |
state = 'pending'; | |
return $http({ | |
url: file.deleteUrl, | |
method: file.deleteType | |
}).then( | |
function () { | |
state = 'resolved'; | |
$scope.clear(file); | |
}, | |
function () { | |
state = 'rejected'; | |
} | |
); | |
}; | |
} else if (!file.$cancel && !file._index) { | |
file.$cancel = function () { | |
$scope.clear(file); | |
}; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment