Add the element wherever you want to bind a [File | FileList] into a class model without additional elements.
Can also drop a file(s) into the component to bind the file(s) to it.
Example for usage:
<td-file-input [(ngModel)]="files" color="primary" (select)="selectEvent($event)" accept=".ext,.anotherExt" [disabled]="disabled" multiple> <mat-icon>attach_file</mat-icon><span>Choose a file...</span> </td-file-input>
export class Demo { files: File | FileList; disabled: boolean = false; selectEvent(files: FileList | File): void { if (files instanceof FileList) { ... } else { ... } }; }
<input/>
element.Import the [CovalentFileModule] in your NgModule:
import { CovalentFileModule } from '@covalent/core/file'; @NgModule({ imports: [ CovalentFileModule, ... ], ... }) export class MyModule {}
Add the directive wherever you want to bind a [File | FileList] into a class model to an existing element.
Uses optional [(ngModel)] directive to bind file. (if [(ngModel]) exists, [fileSelect] is omitted)
Example for usage:
<input type="file" tdFileSelect (fileSelect)="files = $event" multiple>
Add the directive wherever you want to add drop support to an element to bind a [File | FileList] into a class model.
To add effect when ondragenter event is executed, override .drop-zone class in the context you are using it.
Note: if element has child elements, add * { pointer-events: none; } to avoid event being thrown again while navigating in child elements.
Example for usage:
<div tdFileDrop (fileDrop)="files = $event" multiple [disabled]="disabled"> </div>