Angular4搜索错误as it.toLowerCase()。includes(searchText);不是功能

时间:2018-05-24 06:21:33

标签: angular angular4-forms

这里我写了一个简单的搜索功能,它通过一个错误,因为it.toLowerCase()。includes(searchText);

搜索代码

@Pipe({
  name: 'filter'
})
export class FilterPipe implements PipeTransform {
    debuger;
  transform(items: any[], searchText: string): any[] {
    if(!items) return [];
    if(!searchText) return items;
searchText = searchText.toLowerCase();
return items.filter( it => {
      return it.toLowerCase().includes(searchText);
    });
   }
}

表格

    <input [(ngModel)]="searchText" placeholder="enter search term here">
<table  class="table table-sm">
                  <thead>
                      <tr>
                        <th>Auction ID</th>
                        <th>Auction Name</th>
</thead>
                    <tbody>

               <tr *ngFor="let value of auction?.data | filter :searchText">
<tr>
                        <th>Auction ID</th>
                        <th>Auction Name</th>
                       <tr/>

0 个答案:

没有答案