HTML
<nz-dropdown class="filter-dropdown" [nzTrigger]="'click'" nzPlacement="bottomRight">
<a nz-dropdown nz-tooltip nzTitle="Feature not functional">
{{ activeFilter.filterBy }} <i nz-icon [type]="activeFilter.order === 'ASC' ? 'up' : 'down'"></i>
</a>
<ul nz-menu>
<li class="filter-dropdown-item" nz-menu-item (click)="handleFilter('filterBy', 'Application')">Application</li>
<li class="filter-dropdown-item" nz-menu-item (click)="handleFilter('filterBy', 'Date')">
Date
<i nz-icon nzType="check" nzTheme="outline"></i>
</li>
<li nz-menu-divider></li>
<li class="filter-dropdown-item" nz-menu-item (click)="handleFilter('status', 'ALL')">All</li>
<li class="filter-dropdown-item" nz-menu-item (click)="handleFilter('status', 'ACK')">Acknowledged</li>
<li class="filter-dropdown-item" nz-menu-item (click)="handleFilter('status', 'READ')">Read</li>
<li class="filter-dropdown-item" nz-menu-item (click)="handleFilter('status', 'NEW')">New</li>
<li nz-menu-divider></li>
<li class="filter-dropdown-item" nz-menu-item (click)="handleFilter('order', 'ASC')">Ascending</li>
<li class="filter-dropdown-item" nz-menu-item (click)="handleFilter('order', 'DESC')">Descending</li>
<li nz-menu-divider></li>
<li class="filter-dropdown-item" nz-menu-item (click)="handleFilter('grouped', true)">Grouped</li>
<li class="filter-dropdown-item" nz-menu-item (click)="handleFilter('grouped', false)">Ungrouped</li>
</ul>
</nz-dropdown>
TS
activeFilter = {
filterBy: 'Date',
length: 100,
status: 'ALL',
order: 'ASC',
grouped: false
};
handleFilter(targetFilter?: string, value?: any) {
this.activeFilter[targetFilter] = value;
console.log(this.activeFilter);
if (targetFilter === 'order') {
// ?direction = 'asc' || 'desc']
}
}
如何使其多部分选择过滤?这是列表的示例:https ://i.stack.imgur.com/QJKAg.png
选择下拉菜单时应该有默认值Date->All->Ascending->Ungrouped