I would like to select all the value of an input of type number when this input is clickd
I found this question
https://forum.ionicframework.com/t/ion-input-select-all-text-on-focus/79406
but it works only with type text
I would like to select all the value of an input of type number when this input is clickd
I found this question
https://forum.ionicframework.com/t/ion-input-select-all-text-on-focus/79406
but it works only with type text
You can use
<ion-list>
<ion-item>
<ion-label>Input Label</ion-label>
<ion-input type="number"(ionFocus)="selectAllText($event)" [(ngModel)]="inputValue"></ion-input>
</ion-item>
</ion-list>
<!-- TypeScript -->
import { Component } from '@angular/core';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
inputValue: string;
selectAllText(event: any) {
const inputElement = event.target.querySelector('input') as HTMLInputElement;
inputElement.select();
}
}