busqueda para eventos por nombre

This commit is contained in:
onsaliyo 2021-06-04 17:57:04 +02:00
parent 373662895e
commit e9fbef0cac
3 changed files with 31 additions and 0 deletions

View File

@ -6,6 +6,10 @@
<ion-content>
<ion-grid>
<ion-row class="searchbar">
<ion-input class="text" id="filtro"></ion-input>
<ion-button (click)="filtrarEventos()"><ion-icon name="search-outline"></ion-icon></ion-button>
</ion-row>
<ion-row>
<ion-col size="12">
<div *ngIf="eventos.length>0" class="eventos">

View File

@ -0,0 +1,3 @@
.searchbar{
float: right;
}

View File

@ -5,6 +5,7 @@ import { DiscotecaI } from '../interfaces/discoteca-i';
import { ApiService } from '../services/api.service';
import { FeedService } from '../services/feed.service';
import { Tab1Service } from '../tab1/tab1.service';
import { EventListenerFocusTrapInertStrategy } from '@angular/cdk/a11y';
@Component({
selector: 'app-feed',
@ -16,9 +17,12 @@ export class FeedPage implements OnInit {
eventos: Eventoi[];
discotecas: DiscotecaI[];
idsDiscoteca: number[];
mostrarTodos: boolean;
constructor(private feedService:FeedService, private tab1Service: Tab1Service, private router:Router, private apiService: ApiService ) { }
ngOnInit() {
this.mostrarTodos = true;
this.eventos = this.feedService.eventos;
this.idsDiscoteca = [];
this.discotecas=[];
@ -54,6 +58,26 @@ export class FeedPage implements OnInit {
)
}
filtrarEventos(){
var filtro = (<HTMLInputElement>document.getElementById("filtro")).value;
let eventoSinFiltrar = this.feedService.eventos;
this.eventos = [];
eventoSinFiltrar.forEach(evento => {
if (this.cumpleFiltro(evento, filtro)){
this.eventos.push(evento);
}
})
}
cumpleFiltro(evento: Eventoi, filtro: string){
if(evento.nombre.includes(filtro)){
return true;
}
else return false;
}
}