creado feed component. llamada a la API para descargar todos los eventos
This commit is contained in:
@@ -3,7 +3,7 @@ import { stringify } from 'querystring';
|
||||
import { Tab1Page } from './tab1.page'
|
||||
import { Discoteca } from '../discoteca'
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { NumericValueAccessor } from '@ionic/angular';
|
||||
import { DiscotecaI } from '../interfaces/discoteca-i';
|
||||
import { ApiService } from '../services/api.service';
|
||||
@@ -65,7 +65,7 @@ export class Tab1Service implements OnInit{
|
||||
|
||||
initEventos(): void{
|
||||
this.eventos = [];
|
||||
this.apiService.getEventos(this.discoteca.getId())
|
||||
this.apiService.getEventosDiscoteca(this.discoteca.getId())
|
||||
.subscribe(eventos => {
|
||||
this.eventos = eventos;
|
||||
this.router.navigate(['/tabs/tab1/perfil-discoteca']);
|
||||
@@ -76,6 +76,25 @@ export class Tab1Service implements OnInit{
|
||||
|
||||
initEventoForms(): void{
|
||||
this.eventoForms = [];
|
||||
if (this.eventos){
|
||||
this.eventos.forEach(evento => {
|
||||
let thisForm = new FormGroup({
|
||||
nombre: new FormControl(null, Validators.required),
|
||||
fecha: new FormControl(null, Validators.required),
|
||||
hora: new FormControl(null, Validators.required),
|
||||
precio1: new FormControl(null, Validators.required),
|
||||
precio2: new FormControl(null, Validators.required),
|
||||
descripcion: new FormControl(null, Validators.required),
|
||||
});
|
||||
thisForm.controls['nombre'].setValue(evento.nombre);
|
||||
thisForm.controls['fecha'].setValue(evento.fecha);
|
||||
thisForm.controls['hora'].setValue(evento.hora);
|
||||
thisForm.controls['precio1'].setValue(evento.precio1);
|
||||
thisForm.controls['precio2'].setValue(evento.precio2);
|
||||
thisForm.controls['descripcion'].setValue(evento.descripcion);
|
||||
this.eventoForms.push(thisForm);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
getEventobyIndex(eventoIndex: number){
|
||||
@@ -91,6 +110,7 @@ getDiscoteca(discotecaId: number){
|
||||
this.initValues();
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
postEvento(evento: Eventoi){
|
||||
@@ -105,4 +125,6 @@ getDiscoteca(discotecaId: number){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user