Created
March 8, 2020 11:23
-
-
Save AnteaterKit/500af69ec0d204a30797fd17afe525a7 to your computer and use it in GitHub Desktop.
angular drag and drop file directive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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