I need to filter only those objects whose categoria
is a
. Is there any way to achieve this using ngFor?
service.ts :
productos: Producto[] = [
{id:'01', categoria:'a', titulo:'title1'},
{id:'02', categoria:'b', titulo:'title2'},
{id:'03', categoria:'a', titulo:'title3'},
{id:'04', categoria:'c', titulo:'title4'},
{id:'05', categoria:'c', titulo:'title5'}
]
getProductos() {
return of(this.productos);
}
component.ts :
ngOnInit() {
this.productos$ = this.ps.getProductos();
}
component.html :
<div *ngFor="let producto of productos$ | async">
{{ producto.titulo}}
</div>