I am trying to set a costume attribute directive to an input but I couldn't find the way to do it.
My directive is the following
@Directive({
selector: '[disable-paste]'
})
export class DisablePaste {
constructor(private _elementRef:ElementRef) {
this._elementRef.nativeElement.onpaste = (e:any) => {
e.preventDefault();
}
}
}
If I just put the directive by its own in the input, it works. But when I try to use it "conditionally" it doesn't. I tried all these:
<input [disable-paste]="doNotAllowPaste" ... />
<input disable-paste="doNotAllowPaste" ... />
<input [attr.disable-paste]="doNotAllowPaste" ... />