Hello I am trying to make a custom pipe filter which filters the data when checkbox is checked. I have a list of job locations which I want to filter when the certain job location is checked. I am providing the code which is related to the issue/problem.
Pipe code -
@Pipe({
name: 'checkcity'
})
export class CheckcityPipe implements PipeTransform {
transform(check: any, checked: any): any {
let [loc] = checked;
console.log('checked',checked);
return checked
? check.filter(city => {return city.location })
: check;
}
}
Input Checkbox -
<input type="checkbox" value="" [(ngModel)]="checked" name="checked"> Bangalore
Data to filter -
<div *ngFor="let joblist of jobList | checkcity: checked">
{{joblist.location}}
</div>
let [loc] = checked;supposed to do`?return city.locationreturn? Is it supposed to filter all elements wherecity.locationcontains a value?