I am currently working with Ionic 3.x on my macOS system.
The issue I am facing is as follows:
I have an array that contains a number and another array consisting of names.
table: { number: number, names: string[] } = {
number: 0,
names: ['']
};
My goal is to allow the user to input a number to set within the array. In my search for a solution, I came across the AlertController.
To address this requirement, I have created the following function to handle adding a number:
addTable(){
let prompt = this.alertCtrl.create({
title: 'Add Table',
subTitle: 'Enter the table number',
inputs: [{
name: 'tableNumber',
placeholder: 'Number',
type: 'number'
}],
buttons: [
{
text: 'Cancel'
},
{
text: 'Add',
handler: data => {
//this.tables.push(data);
this.table.number = data;
}
}
]
});
prompt.present();
}
However, I am encountering an issue where setting table.number results in [object]. Even when trying to convert it using +data, the value becomes NaN. Additionally, the push method does not yield the desired outcome either.
Could you please provide guidance on how to effectively assign the user-inputted number to table.number?