Created
July 8, 2019 13:14
-
-
Save Muzammil-Bilwani/270bbc8768b8f5f4ad68ac9009f33a76 to your computer and use it in GitHub Desktop.
Block Copy Paste in Angular for Input fields
This file contains 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, HostListener } from '@angular/core'; | |
@Directive({ | |
selector: '[CopyPasteBlock]' | |
}) | |
export class CopyPasteBlockDirective { | |
constructor() { } | |
@HostListener('paste', ['$event']) blockPaste(e: KeyboardEvent) { | |
e.preventDefault(); | |
} | |
@HostListener('copy', ['$event']) blockCopy(e: KeyboardEvent) { | |
e.preventDefault(); | |
} | |
@HostListener('cut', ['$event']) blockCut(e: KeyboardEvent) { | |
e.preventDefault(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I want to know any chance to disable cut copy paste menu. not only the function for cut copy and paste. Thanks