Drag and drop directive adds a behavior to elements in your Angular applications where you can receive a list of files
Report Bug
·
Wiki
To get a local and running follow these simple steps.
Install NPM packages
- npm
npm install npm@latest -g
- With npm installed, run.
npm i @cesarbr/angular-dragndrop-input
Import NgDragndropInput on module
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { NgDragndropInput } from 'ng-dragndrop-input';
@NgModule({
declarations: [AppComponent],
imports: [NgDragndropInput],
providers: [],
bootstrap: []
})
export class AppModule { }
Using the directive on your component and listen 'fileDropped' emitter
<div dragndrop
(fileDropped)="uploadFiles($event)">
<button
class="upload-button">Upload Documents</button>
</div>
FileDropped event emitter a 'FileList' you can use as you prefer
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
@Component({
selector: 'app-button-with-drop',
templateUrl: './button-with-drop.component.html',
styleUrls: ['./button-with-drop.component.scss']
})
export class ButtonWithDropComponent implements OnInit {
@Output() filesToUpload = new EventEmitter<any>();
public uploadFiles(fileList: any) {
this.filesToUpload.emit(fileList);
}
}
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature-IssueNumber
) - Commit your Changes (
git commit -m 'Create a new feature or fix bug'
) - Push to the Branch (
git push origin feature-IssueNumber
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Project Link: https://github.com/CESARBR/angular-dragndrop-input