【发布时间】:2018-09-24 00:29:33
【问题描述】:
我有一个应用程序表,其中包含两列 - appAcronym 和 appName。大约有 250 行应用程序。我想在表格顶部/标题上实现搜索以按 appAcronym 过滤,以便用户可以快速访问所需的行。
数据如下所示:
export interface App {
appId: number;
appName: string;
appAcronym: string;
}
这是我的申请表
<table class="table table-striped table-hover table-sm" *ngIf="appsList">
<thead>
<tr>
<th scope="col">Acronym</th>
<th scope="col">System Name</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let app of appsList">
<td>{{ app.appAcronym }}</td>
<td>{{ app.appName }}</td>
</tr>
</tbody>
</table>
这是我在实现管道时的尝试
import { Pipe, PipeTransform } from '@angular/core';
import { App } from './components/applevel/applevel.component';
@Pipe({ name: 'searchByAcronym' })
export class SearchByAcronymPipe implements PipeTransform {
transform(appslist: App[], searchText: string, appAcronym: string) {
}
我不熟悉管道,如您所见,我将 transform 的内部留空。管道是完成这项工作的最佳工具吗?如果是这样,你能建议如何让它工作吗?理想的实现是在表的 Acronym 标题上进行搜索。但是外部搜索栏也可以。
【问题讨论】:
标签: angular html-table pipes-filters