cambios en el aspecto. Validators en el formulario de evento.
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user