我正在将Angular 8与ng2-search-filter一起使用来过滤列表。
我有以下代码:
<input class="form-control" type="text" placeholder="Search by Title, Keyword, or File Type.." name="search" autofocus [(ngModel)]="filterBar">
...
<tr *ngFor="let media of medias | orderBy: key : reverse | filter:filterBar | paginate: { itemsPerPage: 5, currentPage: p }; let i = index">
<td>{{media.name}}</td>
</tr>
这可以按预期工作,并根据搜索栏中输入的值过滤列表。
问题
是否可以过滤两个项目?
我想添加一个下拉框,如果用户选择一个项目,它也会在该项目上进行过滤。
例如:
<mat-form-field>
<mat-label>Order By</mat-label>
<mat-select [(value)]="selected">
<mat-option *ngFor="let media of medias">{{media.type}}</mat-option>
</mat-select>
</mat-form-field>
<p>You selected: {{selected}}</p>
我想要对所选media.type
进行其他过滤。
更多信息:
这是json数据:
medias = [
{
"id":"1",
"name": "Video File 1",
"type": "Videos"
},
{
"id":"2",
"name": "Interactive Video File 1",
"type": "Interactive Videos"
},
{
"id":"3",
"name": "Audio File 1",
"type": "Audio"
},
{
"id":"4",
"name": "Image File 1",
"type": "Images"
},
{
"id":"5",
"name": "Document File 1",
"type": "Documents"
},
{
"id":"6",
"name": "Video File 2",
"type": "videos"
},
{
"id":"7",
"name": "Audio File 2",
"type": "Audio"
},{
"id":"8",
"name": "Image File 2",
"type": "Images"
},{
"id":"9",
"name": "Video File 3",
"type": "Videos"
},{
"id":"10",
"name": "Document File 2",
"type": "Documents"
}
];