Angular 2使用带JSON的过滤器

时间:2017-08-25 05:42:31

标签: json angular angular2-template angular2-forms angular2-directives

我的问题是我想使用数字过滤器代替字符串过滤器。什么是代码行?

import { PipeTransform, Pipe } from '@angular/core';

import {index} from './index';

@Pipe({
    name:'bookFilter',
})

export class BookFilterPipe implements PipeTransform

{

    transform(value:index[],filterBy:any):index[]
    {
        filterBy=filterBy?filterBy.toLocaleLowerCase():null;
        return filterBy?value.filter((book:index)=>  

        book.Name.toLocaleLowerCase().indexOf(filterBy)!==-1):value  
        // here I want to use year filter in that line. 
       // like **book.year**       what will be full line of code in that place
    }
}

0 个答案:

没有答案