How can I use something typed by the user in an alert entry to create an item in a list if it clicks ok, and the title of that item is what it typed?


#1

The code is this:
import { Component } from ‘@angular/core’;
import { IonicPage, NavController, NavParams } from ‘ionic-angular’;
import { AlertController } from ‘ionic-angular’;
import { SimuladorPage } from ‘…/simulador/simulador’;

@IonicPage()
@Component({
selector: ‘page-tab3’,
templateUrl: ‘tab3.html’,

})
export class Tab3Page {

constructor(public navCtrl: NavController, public navParams: NavParams,public alertCtrl: AlertController) {

}
doPrompt() {
let prompt = this.alertCtrl.create({
title: ‘Simule suas compras!’,
message: “Crie um nome para a sua lista de compras:”,
inputs: [
{
name: ‘title’,
placeholder: ‘Exemplo: Compras do mês’,
id:‘1’
},
],
buttons: [
{
text: ‘Cancele’,
handler: data => {
console.log(‘Cancel clicked’);
}
},
{
text: ‘Salve’,
handler: data => {
console.log(‘Saved clicked’)

      }
    }
  ]
});
prompt.present();

}

ionViewDidLoad() {
console.log(‘ionViewDidLoad Tab3Page’);

}

}