3

inside an Angular directive I want to check if input text is selected,so I use this.el.nativeElement.selectionEnd and this.el.nativeElement.selectionStart but all are null,is there any clue? thanks

export class myDirective {

  constructor(private el: ElementRef) {}

  @HostListener('keydown', ['$event'])
  onKeyDown(event: KeyboardEvent) {
     console.log(this.el.nativeElement.selectionStart);
  }
}
mrapi
  • 5,831
  • 8
  • 37
  • 57

0 Answers0