From 5357a243f6d1ec9bbb70e973460ff773b2c4f361 Mon Sep 17 00:00:00 2001 From: David Martins Date: Wed, 4 Oct 2017 16:36:48 -0300 Subject: [PATCH] Added event with return of request --- src/file-upload/file-uploader.class.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/file-upload/file-uploader.class.ts b/src/file-upload/file-uploader.class.ts index 5f17770f..998352cb 100644 --- a/src/file-upload/file-uploader.class.ts +++ b/src/file-upload/file-uploader.class.ts @@ -1,3 +1,4 @@ +import { EventEmitter } from '@angular/core'; import { FileLikeObject } from './file-like-object.class'; import { FileItem } from './file-item.class'; import { FileType } from './file-type.class'; @@ -43,6 +44,7 @@ export class FileUploader { public _nextIndex:number = 0; public autoUpload:any; public authTokenHeader: string; + public response: EventEmitter; public options:FileUploaderOptions = { autoUpload: false, @@ -56,6 +58,7 @@ export class FileUploader { public constructor(options:FileUploaderOptions) { this.setOptions(options); + this.response = new EventEmitter(); } public setOptions(options:FileUploaderOptions):void { @@ -358,6 +361,11 @@ export class FileUploader { xhr.setRequestHeader(this.authTokenHeader, this.authToken); } xhr.send(sendable); + xhr.onreadystatechange = function() { + if (xhr.readyState == XMLHttpRequest.DONE) { + this.response.emit(xhr.responseText) + } + } this._render(); }