How to use item.isUploading to show an alert if the user tries to navigate away while uploading. #899

Open
opened 2017-10-04 16:03:14 +00:00 by moguidry · 1 comment
moguidry commented 2017-10-04 16:03:14 +00:00 (Migrated from github.com)

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?

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?
adrianfaciu commented 2017-10-05 07:02:47 +00:00 (Migrated from github.com)

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.

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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#899