angular / angular/components

Angular Material, Autocomplete loading indicator and showing text (no results found)

未关闭
#18,478 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area: material/autocomplete docs help wanted P3
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

#### Feature Description

I need to show loading when searching for data and also show text when no record is found.
I have the following html excerpt:
```html

arrow_drop_down






{{
index !== to.filterKeys.length - 1
? value[ky] + ' - '
: value[ky]
}}


{{ value }}


```

Component.ts code:
```javascript
ngOnInit(): void {
super.ngOnInit();

this._unsubscribeAll = new Subject();
this.isLoading = false;

this.result$ = this.formControl.valueChanges.pipe(
takeUntil(this._unsubscribeAll),
debounceTime(300),
startWith(''),
tap(() => {
this.isLoading = true
}),
switchMap(term => this.to.filter(term))
);
}
```

for loading, I would control it with the `tap()` method, but my problem is how to know that the request inside `switchMap(term => this.to.filter(term))` was finished, so I set the loading variable to false?

my second problem is how to show a registration message not found, when the server returns an empty array, because I am working with async.

贡献指南

打开贡献指南

调研方向

从提供的 Angular 模板和 ngOnInit 中的 valueChanges 管道开始,然后查看 Angular Material autocomplete 文档及相关示例。当 autocomplete 能够明确显示正在进行搜索,并且在异步结果为空时显示无结果消息时,即视为完成;未指定任何 repository 文件或测试。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
frontend
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
需要澄清
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。