【发布时间】:2019-11-29 13:32:38
【问题描述】:
我正在尝试在单击后过滤表格中的对象。
HTML
<form [formGroup]="form" (ngSubmit)="onSubmit(searchValue)">
<mat-form-field class="filter" floatLabel="never">
<mat-label>Name</mat-label>
<input matInput formControlName="nameFilter" [value]="searchValue">
</mat-form-field>
<button mat-raised-button class="search">Search</button>
</form>
TS
onSubmit(){
this.ListService.getList(this.currentUser().my_token, this.form.value).then(res => {
this.nameFilter.valueChanges.subscribe(name => {
this.filterValue.name = name;
this.dataSource.filter = JSON.stringify(this.filterValue);
});
})
}
服务
getList(token, frm) {
return new Promise((resolve, reject) => {
return this.http.post<any>("my_path",
{
'token': token,
'frm':
{
'id': frm.id,
'name' : frm.name
}
})
当我在输入中输入名称并单击搜索按钮时,我希望与输入名称匹配的所有名称都出现在表中。 我哪里做错了?
【问题讨论】:
标签: angular search service onclick angular-material