Skip to content

Instantly share code, notes, and snippets.

@partageit
Created September 11, 2014 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save partageit/34b897738edb4695c890 to your computer and use it in GitHub Desktop.
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
'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