So I wanted to add a maximum characters amount to an input field in an alert, and according to the alertContoller docs (https://ionicframework.com/docs/v2/api/components/alert/AlertController/) there should be min and max properties in Input options, I also looked around and found the original feature requests and commits. However, when I try to use it in my code it tells me the argument type is not allowed
Argument of type ‘{ title: string; subTitle: string; inputs: { name: string; placeholder: string; type: string; max…’ is not assignable to parameter of type ‘AlertOptions’. Types of property ‘inputs’ are incompatible. Type ‘{ name: string; placeholder: string; type: string; max: any; }[]’ is not assignable to type ‘AlertInputOptions[]’. Type ‘{ name: string; placeholder: string; type: string; max: any; }’ is not assignable to type ‘AlertInputOptions’. Object literal may only specify known properties, and ‘max’ does not exist in type ‘AlertInputOptions’.
I tried using npm install ionic to get the latest version and still nothing. Here is my code:
newObserver(){
let alert1 = this.alertCtrl.create({
title: ‘New Observer’,
subTitle: ‘Enter the name of the new Observer’,
inputs: [
{
name: ‘Name’,
placeholder: ‘Name’,
type: ‘text’,
max: 50
}
],
buttons:[
{text: ‘Cancel’},
{text:‘Save’,
handler: data => {
console.log(data);
this.fieldDataService.observers.push(data.Name);
this.addObsForm.controls[‘name’].setValue(data.Name);
}}
]
});
alert1.present();
}