From fdb99b149e9038d6f120dda567c3d3e1dd801159 Mon Sep 17 00:00:00 2001 From: YaroslavOsetrov Date: Tue, 13 Sep 2016 22:19:32 +0300 Subject: [PATCH] Dynamic options parameter binding (#84) This changes will allow to bind options parameter dynamically. For example, when we use dynamic URLs --- src/directives/ng-file-drop.ts | 14 +++++++++++++- src/directives/ng-file-select.ts | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/directives/ng-file-drop.ts b/src/directives/ng-file-drop.ts index 0dd3f818..671d8c42 100644 --- a/src/directives/ng-file-drop.ts +++ b/src/directives/ng-file-drop.ts @@ -12,11 +12,23 @@ import {Ng2Uploader} from '../services/ng2-uploader'; selector: '[ngFileDrop]' }) export class NgFileDropDirective { - @Input() options: any; + @Input() events: EventEmitter; @Output() onUpload: EventEmitter = new EventEmitter(); @Output() onPreviewData: EventEmitter = new EventEmitter(); + _options:any; + + get options(): any { + return this._options; + } + + @Input('options') + set options(value: any) { + this._options = value; + this.uploader.setOptions(this.options); + } + files: any[] = []; uploader: Ng2Uploader; diff --git a/src/directives/ng-file-select.ts b/src/directives/ng-file-select.ts index a5fe8781..10d99e66 100644 --- a/src/directives/ng-file-select.ts +++ b/src/directives/ng-file-select.ts @@ -12,10 +12,22 @@ import { Ng2Uploader } from '../services/ng2-uploader'; selector: '[ngFileSelect]' }) export class NgFileSelectDirective { - @Input() options: any; + @Input() events: EventEmitter; @Output() onUpload: EventEmitter = new EventEmitter(); @Output() onPreviewData: EventEmitter = new EventEmitter(); + + _options:any; + + get options(): any { + return this._options; + } + + @Input('options') + set options(value: any) { + this._options = value; + this.uploader.setOptions(this.options); + } files: any[] = []; uploader: Ng2Uploader;