Angular 2 select text on specific input

You can easily do it in the template like this:

<input type="text" (click)="$event.target.select()" />

or add a local variable to your element and reference that instead:

<input type="text" #myInput (click)="myInput.select()" />

The benefit of the second approach is that by setting a local variable name to your element, other elements can reference that variable as well.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)