Am trying to create a angular 2 pipe for the array of elements so that it filters the only that elements based on the selected false,
my array
this.states = [ {name: 'John', selected: false, value: 1}, {name: 'Bill', selected: false, value: 2},
{name: 'Smith', selected: false, value: 3}, {name: 'Alex', selected: false, value: 4},
{name: 'Martin', selected: false, value: 5}, {name: 'James', selectes: false, value: 6}];
I need to filter the value which is of selected false,
My Pipe Code
import {Injectable,Pipe} from 'angular2/core';
@Pipe ({
name : 'restrictValues'
})
@Injectable()
export class restrictValues implements PipeTransform {
transform(items: any[], args: any[]): any {
return items.filter(item => item.id.indexOf(args[1]) !== true);
}
}
My HTML Implementation
<select ngControl="select_state" (change)="statechange()" #select_state="ngForm" class="form-control btn btn-primary">
<option *ngFor="#statez of states | restrictValues : false" value="{{statez.value}}">
{{statez.name}}
</option>
</select>
The pipes in not working as expected please correct me if any thing is wrong in the code