Good day, everyone. I am facing this problems in my project which is Type Script error TS2554: Expected 0 arguments, but got 1. This error make me cannot create a select the other option for custom input pop up. In this forum, I have post the typescript code and error part of the typecript code.
The error code of the typescript
Typescript Code
import { Validators, FormBuilder, FormGroup, FormControl } from '@angular/forms';
import { AlertController } from '@ionic/angular';
constructor(
public formBuilder: FormBuilder,
public alertController: AlertController
) { }
ngOnInit() {
this.religions = [
"Islam",
"Buddha",
"Hinduism",
"Christian",
"Sikhism",
"Taiosm",
"Other"
];
this.currentReligionValue = "Islam";
this.validations_form = this.formBuilder.group({
religion: new FormControl(this.currentReligionValue, Validators.required),
});
}
validation_messages = {
'religion': [
{ type: 'required', message: 'Religion is required to select' },
};
//When have other values
selectChanged(selected) {
if (selected === 'Other') {
this.inputValue();
} else {
this.currentvalue = selected;
};
};
The error part in the TypeScript
async inputValue() {
const inputAlert = await this.alertController.create({
header: 'Enter your custom color:',
inputs: [ { type: 'text', placeholder: 'type in' } ],
buttons: [ { text: 'Cancel' }, { text: 'Ok' } ]
});
inputAlert.onDidDismiss((data) => { //<-- The error part is starting here
let customName: string = data.data.values[0];
if (customName) {
let indexFound = this.religions.findIndex(religion => religion === customName)
if (indexFound === -1) {
this.religions.push(customName);
this.currentReligionValue = customName;
} else {
this.currentReligionValue = this.religions[indexFound];
};
};
}).catch(err=>console.log(err));
await inputAlert.present();
};
question from:
https://stackoverflow.com/questions/65846565/type-script-error-ts2554-expected-0-arguments-but-got-1-in-ionic-application 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…