I have a table with data from database and I need to filter that table using dropdown menu. Thing is, the table isn't getting filtered even when I manage to get the filtered table on console: It's just the front end not showing. My filter function is the following:
FiltrarTipoGestion(data) {
let tipoGestion = data;
if (data != "0") {
this.listPerfilamiento2 = this.listPerfilamiento.filter(x => x.tipoGestionDescripcion.toLowerCase() == tipoGestion.toLowerCase());
} else {
this.listPerfilamiento2 = this.listPerfilamiento;
}
}
The filter in the HTML is this :
<label class="col-lg-1 float-left">Tipo de gestión</label>
<div class="col-lg-2 float-left">
<select (change)="FiltrarTipoGestion($event.target.value)" [(ngModel)]="perfilamiento.tipoGestionDescripcion" class="form-control form-control-sm">
<option *ngFor="let tg of listTipoGestion;" value="{{tg.nombre}}">{{tg.nombre}}</option>
</select>
</div>
I've reduced my error being in the front end filter, since I'm able to get data filtered when i do console.log. Any help or tip is appreciated.
Edit : the array gets the data from here:
this._service.getListarPerfilamiento(this.TipoPerfilId).subscribe((data) => {
this.listPerfilamiento = data['data'];
this.listPerfilamiento2 = data['data'];
this.listPerfilamientoAll = data['data'];
if (this.TipoPerfilId == 1) {
this.ShowAgencia = true;
this.ShowMensajeria = false;
} else {
this.ShowAgencia = false;
this.ShowMensajeria = true;
}
})