In order to find the perfect products, I need to utilize the myfilters filter. Unfortunately, this is not currently working as expected.
Here is a snippet of the store's HTML:
<h2>store</h2>
<select>
<option *ngFor="let g of GenderFilter">{{g.DisplayText}}</option>
</select>
<select>
<option *ngFor="let p of PriceFilter">{{p.DisplayText}}</option>
</select>
<tr *ngFor="let P of products | filer : p | orderBy: 'PriceFilter'">
<td>{{p.DisplayText}}</td>
</tr>
Filter Pipe Code:
export class FilerPipe implements PipeTransform {
transform(items: any[], term): any {
console.log('term', term);
return term
? items.filter(item => item.ProductTags.indexOf(term) !== -1)
: items;
}
}
Order by Pipe Code:
transform(items: Array<string>, orderBy: string): Array<string> {
if (items !== undefined) {
items.sort((a: any, b: any) => {
if (a[orderBy] < b[orderBy]){
return -1;
} else if (a[orderBy] > b[orderBy]) {
return 1;
} else {
return 0;
}
});
}
return items;
}
The key to displaying the right products lies in ensuring they have the same "tag" as the filter applied.