Skip to content

ngx-dropfiles is an Angular 5 module for desktop drag’n’drop files

License

Notifications You must be signed in to change notification settings

digitalascetic/ngx-dropfiles

Repository files navigation

@digitalascetic/ngx-dropfiles

@digitalascetic/ngx-dropfiles is an Angular 6 module for desktop drag’n’drop files

Important

@digitalascetic/ngx-dropfiles Angular 5 compatibility is under version 1.0.4

$ npm install @digitalascetic/ngx-dropfiles@1.0.4 --save

Install

  1. Add @digitalascetic/ngx-dropfiles module as dependency to your project.
$ npm install @digitalascetic/ngx-dropfiles --save
  1. Include NgxDropfilesModule into your main AppModule or in module where you will use it.
// app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgxDropfilesModule } from 'ngx-dropfiles';

@NgModule({
  imports: [
    BrowserModule,
    NgxDropfilesModule
  ],
  declarations: [ AppComponent ],
  exports: [ AppComponent ]
})
export class AppModule {}

Example

import { Component } from '@angular/core';

@Component({
  selector: 'app-home',
  template: `
      <ngx-dropfiles [dropFilesMessage]="'Drag a file here or browse to upload.'" 
                  [acceptedFiles]="'image/jpg', '.png'"
                  (filesDroppped)="manageFiles($event)"
                  (filesDroppedError)="manageFilesError($event)"></ngx-dropfiles>
  `
})
export class AppHomeComponent {
    
    public manageFiles(files: File[]) {
        console.log(files);
    }
    
    public manageFilesError(files: NgxDropfilesError[]) {
           if(files.length > 0) {
                for(let i = 0; i < files.length; i++){
                    console.log('Error: ' + files[i].errorType + 'for file: ' + files[i].file.name);
                }
           }        
    }

About

ngx-dropfiles is an Angular 5 module for desktop drag’n’drop files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published