Hello everyone! I'm encountering an issue in my project involving a Type Script error TS2554: Expected 0 arguments, but got 1. This error is preventing me from being able to select other options for custom input pop up. In this forum post, I have shared the typescript code along with the specific error within the code. View the TypeScript error here
Here is the 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' },
};
//Handling other values
selectChanged(selected) {
if (selected === 'Other') {
this.inputValue();
} else {
this.currentvalue = selected;
};
};
Specific Error Section in TypeScript Code:
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 starts 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();
};