I found several answers here, where people recommend using a line of code similar to this:
<div *ngFor="let x of filter(myArray)">
However, it filter(myArray)starts constantly.
I found that storing 2 arrays like the ones below is much more efficient.
<div *ngFor="let x of filteredArray">
the code
let fullArray = [1,2,3,4,5,6]
let filteredArray = []
onFilterEvent() {
filteredArray = fullArray.filter(x => )
}
The disadvantage here is that I constantly rewrite the contents filteredArray. However, it only works when filtering logic is required, and not constantly.
Is there a reason to use the first method? He still does the same job, but he does it again and again.
source
share