如何将角度2中的可观察数据转换为小写

时间:2016-09-28 06:54:18

标签: angular typescript

详细

我想将可观察数据转换为lowerCase,下面是我的代码。我想将Value转换为小写

代码

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


@Pipe({
    name: "search"
})

export class SearchPipe {

    transform(value, term) {
        console.log(term.toLowerCase());
        if (term == null) {
            return null;
        }
        return value.filter((item) => {
            return item.Email.includes(term) || item.FirstName.includes(term) || item.LastName.includes(term);
        });
    }

}

图像

enter image description here

1 个答案:

答案 0 :(得分:1)

详细

我试过了。它有效。

代码

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


@Pipe({
    name: "search"
})

export class SearchPipe {

    transform(value, term) {
        console.log(value);
        if (term == null) {
            return null;
        }
        return value.filter((item) => {
            return item.Email.toLowerCase().includes(term) || item.FirstName.toLowerCase().includes(term) || item.LastName.toLowerCase().includes(term);
        });
    }
}