Categorias
iiiiii
alerta con formulario
Descripcion
Como hacer un formulario en alert
Nota
<ion-button (click)="presentAlertForm()" expand="block" >
Alerta con formulario
</ion-button>
html
/*
NOTA: para mas tipos de inputs es mejor crear un modal.
*/
import { Component, OnInit } from '@angular/core';
import { AlertController } from '@ionic/angular';
@Component({
selector: 'app-alert',
templateUrl: './alert.page.html',
styleUrls: ['./alert.page.scss'],
})
export class AlertPage implements OnInit {
constructor(private alertController: AlertController) { }
ngOnInit() {
}
async presentAlertForm() {
const alert = await this.alertController.create({
header: 'Please enter your info',
buttons: [{
text:'OK',
handler:(data)=>{
console.log(data); /*DE ESTA FORMA SE ATRAPAN LOS DATOS DEL FORMULARIO*/
}
}],
inputs: [
{
placeholder: 'Name',
name:'nombre'
},
{
name:'nickname',
placeholder: 'Nickname (max 8 characters)',
attributes: {
maxlength: 8,
},
},
{
name:'anio',
type: 'number',
placeholder: 'Age',
min: 1,
max: 100,
},
{
name:'descripcion',
type: 'textarea',
placeholder: 'A little about yourself',
},
],
});
await alert.present();
}
}