How to use item.isUploading to show an alert if the user tries to navigate away while uploading. #899
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I'm working with an Angular 2.0 project using this uploader.
I'm trying to show an alert to the user if they try to refresh or navigate away from the page when a file is uploading. I've found how to do display an error if an item is uploading by using an *ngIf = "item.isUploading," but I have not found any way to subscribe to the event in the controller.
Any ideas?
You could use different functions on the uploader, for example when a file is added:
this.uploader.onAfterAddingFile = () => this.isUploading = true;and then when it completes you handle complete all:
this.uploader.onCompleteAll = () => this.isUploading = false;Then you can show the alert based on the status of this.