@nbxx/nb-input
Version:
Angular - nbinput
39 lines • 1.35 kB
JavaScript
import { Component, EventEmitter, Output } from '@angular/core';
import { NbinputExcelService } from "./nbinput-excel.service";
export class NbinputExcelComponent {
constructor(excel) {
this.excel = excel;
this.loaded = new EventEmitter();
}
onchange(e) {
if (e && e.target && e.target.files && e.target.files.length > 0) {
this.excel.loadExcelFileAsJson(e.target.files[0]).then(f => {
this.loaded.emit(f);
});
e.target.value = '';
// e.target.files = [];
}
}
}
NbinputExcelComponent.decorators = [
{ type: Component, args: [{
selector: 'nbinput-excel',
template: `
<div class="nb-excel-wrapper">
<button class="btn btn-sm">加载 Excel 文件</button>
<input type="file" (change)="onchange($event)" />
</div>
`,
styles: [`
.nb-excel-wrapper{position:relative;overflow:hidden;display:inline-block}.nb-excel-wrapper input[type=file]{position:absolute;left:0;top:0;opacity:0}
`],
},] },
];
/** @nocollapse */
NbinputExcelComponent.ctorParameters = () => [
{ type: NbinputExcelService }
];
NbinputExcelComponent.propDecorators = {
loaded: [{ type: Output }]
};
//# sourceMappingURL=nbinput-excel.component.js.map