UNPKG

ng-uploader

Version:

## ng-uploader [![Angular 2 Style Guide](https://mgechev.github.io/angular2-style-guide/images/badge.svg)](https://github.com/mgechev/angular2-style-guide)

38 lines 1.34 kB
import { Directive, ElementRef } from '@angular/core'; import { NgUploader } from './ng-uploader'; var NgUploadSelectDirective = (function () { function NgUploadSelectDirective(el, uploader) { this.uploader = uploader; this.isUploadBotton = false; this.el = el; this.isValidButton(); this.el.nativeElement.addEventListener('change', this.onChange.bind(this)); } NgUploadSelectDirective.prototype.onChange = function () { var files = this.el.nativeElement.files; this.uploader.addFiles(files); this.reset(); }; NgUploadSelectDirective.prototype.reset = function () { this.el.nativeElement.value = ''; }; NgUploadSelectDirective.prototype.isValidButton = function () { var ele = this.el.nativeElement; if (ele instanceof HTMLInputElement && ele.type === 'file') { this.isUploadBotton = true; } }; return NgUploadSelectDirective; }()); export { NgUploadSelectDirective }; NgUploadSelectDirective.decorators = [ { type: Directive, args: [{ selector: '[ng2UploadSelect]' },] }, ]; /** @nocollapse */ NgUploadSelectDirective.ctorParameters = function () { return [ { type: ElementRef, }, { type: NgUploader, }, ]; }; //# sourceMappingURL=ng-select-directive.js.map