0

Recently, I updated code for ngFor from "#" to "let" and the pipe on one of the existing loop stopped working.

Html looks like this:

<a class="product" *ngFor="let repeatProduct of (_products | CategoryMatchPipe: selectedProductCategory)" (click)="setPreviewProduct(repeatProduct)">
    <div class="img" [ngStyle]="backgroundImageStyle(repeatProduct.mainImageSource)"></div>
    <h4>{{repeatProduct.name}}</h4>
  </a>

There is a pipe, CategoryMatchPipe, used in the ngFor loop on products.

The categoryMatchPipe looks like this:

import {Pipe, PipeTransform} from "angular2/core";

@Pipe(
{
    name: "CategoryMatchPipe"
    ,pure: false                                         
}
)
export class CategoryMatchPipe implements PipeTransform{

    transform(value: any, args? : any){
        if(value){
            let category = args[0];
            return value.filter( product => product.category === category);
        }
    }
}

When I debug the pipe, it seems to be filtering the array fine but I don't see any products. Any idea what is the problem?

D M
  • 417
  • 1
  • 5
  • 9

0 Answers0