Reputation: 1497
Heyy peeps, i've been using ngx-uploader in angular2, in response i'm sending file name thats generated on backend. Response is only sent when file is fully uploaded. So how could i track uploading process which is done by event emitter and looks like this:
files: UploadFile[];
uploadInput: EventEmitter<UploadInput>;
startUpload(): void {
const event: UploadInput = {
type: 'uploadFile',
url: 'http://localhost:3030/upload/quality-docs',
method: 'POST',
file: this.files[this.files.length - 1],
};
this.uploadInput.emit(event);
}
Inside of event.file is percentage value of progress, how do i listen/track it. So when its 100, to do something (get value of name in response)?
Upvotes: 1
Views: 717
Reputation: 1497
After a while i found right way to do this.. in the docs 'readme' there is method called onUploadOutput(output: UploadOutput): void {} in there u need just to add another if statement which would look like
else if(output.type === 'done') { whatever u wanna do}
So usually there's attribute that's being changed depending of the stage. So to know the stage of emitter, u just gotta check value of that property. And yea in this case there also was percentage attribute.
Upvotes: 1