angular2-file-drop
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.0 • Public • Published

    angular2-file-drop

    Angular2 component with Drag and Drop support for files

    Install

    npm install angular2-file-drop

    Usage

    import { Component, Output } from '@angular/core';
    import { FileDropDirective } from 'angular2-file-drop';
     
    @Component({
      selector: 'upload',
      template: `
        <div fileDrop
          [ngClass]="{'file-is-over': fileIsOver}"
          [options]="options"
          (fileOver)="fileOver($event)"
          (onFileDrop)="onFileDrop($event)">
          Drop file here
        </div>
      `,
      directives: [ FileDropDirective ]
    })
    export class PartiesUpload {
      public fileIsOver: boolean = false;
      @Output() public options = {
        readAs: 'ArrayBuffer'
      };
     
      private file: File;
     
      public fileOver(fileIsOver: boolean): void {
        this.fileIsOver = fileIsOver;
      }
     
      public onFileDrop(file: File): void {
        console.log('Got file!');
      }
    }
     

    Options

    • readAs? : DataURL, ArrayBuffer, BinaryString or Text

    Install

    npm i angular2-file-drop

    DownloadsWeekly Downloads

    128

    Version

    0.2.0

    License

    MIT

    Last publish

    Collaborators

    • avatar