Na parte de Pipes, quando remove o filtro do input as fotos vão sumindo aos poucos.
<div class="text-center mt-3 mb-3">
<form>
<input
class="rounded"
placeholder="Search..."
autofocus
(keyup)="filter = $event.target.value"/>
</form>
</div>
<app-photos [photos]="photos | filterByDescription: filter"></app-photos>
import { Pipe, PipeTransform } from '@angular/core';
import { Photo } from '../photo/photo';
@Pipe({
name: 'filterByDescription'
})
export class FilterByDescription implements PipeTransform {
transform(photos: Photo[], descriptionQuery: string): Photo[] {
console.log(photos);
descriptionQuery = descriptionQuery.trim().toLowerCase();
if (descriptionQuery) {
return photos.filter(photo => photo.description.toLowerCase().includes(descriptionQuery));
} else {
return photos;
}
}
}