AngularJS event handling
When using the plugin with jquery.fileupload-angular.js to bind to events (i.e. fileuploadsubmit) I don't think it's possible to cancel the event from within the calling app.
So modyfying app.js to add a listener for the 'fileuploadsubmit' event
.controller('DemoFileUploadController', [
'$scope', '$http', '$filter', '$window',
function ($scope, $http, $filter, $window) {
$scope.loadingFiles = true;
$scope.options = {
url: url,
};
$http.get(url)
.then(
function (response) {
$scope.loadingFiles = false;
$scope.queue = response.data.files || [];
},
function () {
$scope.loadingFiles = false;
}
);
$scope.$on('fileuploadsubmit', function(e, data) {
console.log('This is reached correctly, so the event fires fine');
return false; //this is not passed back to fileUpload
});
}
])
It makes sense to me that this doesn't work, as jquery.fileupload-angular.js simply calls $scope.$emit(e.type, data). But I wonder if there is a way to make this work, I'm concerned also that anything else you do inside $scope.$on is not guaranteed to run at the correct point in the fileUpload event lifecycle
You can now prevent default event actions in Angular scope listeners, too:
$scope.$on('fileuploadsubmit', function (e, data) {
e.preventDefault();
});
Thanks for the super quick response, this is great.