Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

setSelectionRange is not a function

$
0
0

@edwinrikkers wrote:

Ionic 4

I want to try to change the cursor position in an input field like this:

HTML
 <ion-input #urlInput (ionFocus)="onFocus()" type="text" formControlName="url"  autocorrect="off" autocapitalize="none"></ion-input>


COMPONENT
  @ViewChild('urlInput', { read: ElementRef }) inputRef;

onFocus(){
  const element = this.inputRef.nativeElement as HTMLInputElement;
  element.setSelectionRange(0,0);
}

But the console gives the following error: setSelectionRange is not a function
Anyone get any idea how to fix this???

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles