I am struggling with adding an angular2 pipe to my application. I have the following HTML displaying a list of employees that i would like to filter based on location. In this instance I am trying to filter my employees where location = 2.
<ion-item-sliding *ngFor="#employee of employees | location:'2'">
<ion-item-sliding>
The Pipe code is below. When I run it the error that I am receiving is
‘ORIGINAL EXCEPTION: TypeError: Unable to get property ‘filter’ of undefined or null reference’
and
’TypeError: Unable to get property ‘filter’ of undefined or null reference in [employees | location:‘2’ in Page1@7:23]’
import {Pipe, PipeTransform, Injectable} from 'angular2/core';
import {employee} from '../data/employee';
@Pipe({
name: 'location'
})
@Injectable()
export class LocationPipe implements PipeTransform{
transform(employees: employee[], args: any[]) : any{
return employees.filter(item => item.OfficeID.indexOf(args[0]) !== -1);
}
}