cambios en el aspecto. Validators en el formulario de evento.

This commit is contained in:
2021-02-19 13:06:52 +01:00
parent dca38179bb
commit 65658f5aa3
13 changed files with 551 additions and 19 deletions

View File

@@ -10,10 +10,11 @@ import { Router } from '@angular/router';
styleUrls: ['./prompt-evento.page.scss'],
})
export class PromptEventoPage implements OnInit{
submitted = false;
eventoForm = new FormGroup({
nombre: new FormControl('', Validators.required),
fecha: new FormControl('', Validators.required),
hora: new FormControl('', Validators.required),
precio1: new FormControl('', Validators.required),
precio2: new FormControl('', Validators.required),
descripcion: new FormControl('', Validators.required),
@@ -31,9 +32,12 @@ export class PromptEventoPage implements OnInit{
}
}
onSubmit(){
let evento = new Evento();
this.asignarEvento(evento);
this.router.navigate(['/tabs']);
this.submitted = true;
if (this.eventoForm.valid){
let evento = new Evento();
this.asignarEvento(evento);
this.router.navigate(['/tabs']);
}
}
asignarEvento(evento: Evento){
evento.setNombre(this.eventoForm.get('nombre').value);
@@ -56,6 +60,30 @@ export class PromptEventoPage implements OnInit{
this.tab1Service.eventoForms.push(this.eventoForm);}
}
get nombre(){
return this.eventoForm.get('nombre');
}
get fecha(){
return this.eventoForm.get('fecha');
}
get hora(){
return this.eventoForm.get('hora');
}
get precio1() {
return this.eventoForm.get('precio1');
}
get precio2() {
return this.eventoForm.get('precio2');
}
get descripcion(){
return this.eventoForm.get('descripcion');
}
}