I love coding
I love coding

Reputation: 1191

Text keyboard for a number in Ionic

I've an input type element within a modal in my Ionic App:

<ion-input [(ngModel)] = "price" placeholder="Inserisci i crediti" type="number" text-center></ion-input> 

As you can see the type is "number", but the keyboard displayed in the iOs device is the standard text one; why? Is there something wrong with my code?

Upvotes: 0

Views: 1312

Answers (1)

Sinan Samet
Sinan Samet

Reputation: 6742

As you can see in the properties of ion-input you need to give it an inputmode.

inputmode

Description

A hint to the browser for which keyboard to display. Possible values: "none", "text", "tel", "url", "email", "numeric", "decimal", and "search".

Attribute

inputmode Type "decimal" | "email" | "none" | "numeric" | "search" | "tel" | "text" | "url" | undefined

I think this should work:

<ion-input inputmode="numeric" [(ngModel)] = "price" placeholder="Inserisci i crediti" type="number" text-center></ion-input>

Upvotes: 3

Related Questions