import { Directive, ElementRef, HostListener } from '@angular/core';
@Directive({
selector: '[mpnAadharDirective]'
})
export class GeneralDirective {
constructor(private el: ElementRef) { }
@HostListener('keyup') keyup() {
console.log(this.el.nativeElement.value.replace(/\d(?=\d{4})/g, "*"))
}
}
With the above code I'm trying to replace the nativeElement value, but I get the value printed but it is not replacing. I need some help in fixing this. Thank you.
replace: trueflag had come up with more problems than solutions which is why it was removed. therefore you can not builddirectivesin such a way anymore and provide valid html markup. The only workaround is to use anattribute-directiveinstead: