Skip to content

Instantly share code, notes, and snippets.

@AnteaterKit
Created March 8, 2020 11:23
Show Gist options
  • Save AnteaterKit/500af69ec0d204a30797fd17afe525a7 to your computer and use it in GitHub Desktop.
Save AnteaterKit/500af69ec0d204a30797fd17afe525a7 to your computer and use it in GitHub Desktop.
angular drag and drop file directive
import { Directive, ElementRef, HostListener } from '@angular/core';
@Directive({
selector: '[appAsFileDrop]'
})
export class AsFileDropDirective {
private element: HTMLElement;
constructor(private elementRef: ElementRef) {
this.element = elementRef.nativeElement;
}
@HostListener('drop', ['$event'])
public onDrop(event: any): any {
const files = event.dataTransfer.files;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment