gpt4 book ai didi

angular - 无法读取未定义的属性 'toString'

转载 作者:太空狗 更新时间:2023-10-29 19:27:02 24 4
gpt4 key购买 nike

<分区>

数据过滤器.pipe.ts

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

@Pipe({
name: 'dataFilter'
})
export class DataFilterPipe implements PipeTransform {

transform(array: any[], query: string): any {

if (!query || query === '') {
return array;
}

let filtered = [];
array.forEach(function (element) {
let isAdded = false;
Object.keys(element).forEach(function (key, index) {
if (!isAdded && element[key].toString().toLowerCase().includes(query.toLowerCase())) {
filtered.push(element);
isAdded = true;
}
});
});

return filtered;
}

}

在 .html 中

<table class="bordered table-bordered" [mfData]="users | dataFilter : filterQuery" #mf="mfDataTable"

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com