小编Nit*_*jan的帖子

如何在打字稿的输入搜索框中添加去抖动时间?

如何将去抖动时间添加到在表数据上搜索数据的动态搜索框?我在网站上查看了一些解决方案,但我的代码有点不同,我没有使用任何油门或其他东西,所以我很困惑。

我的模板代码:

<input matInput (keyup)="applyFilter($event.target.value)" placeholder="Search element">
Run Code Online (Sandbox Code Playgroud)

和打字稿是:

applyFilter(filterValue: string) {
    this.tableDataSource.filter = filterValue.trim().toLowerCase();
}
Run Code Online (Sandbox Code Playgroud)

我想添加去抖动时间,以便每 2 秒进行一次搜索,而不是为每次更改发送大量请求。

提前致谢

我试图用管道从另一个方法调用该方法

filterData(filterValue: string) {
    this.applyFilter(filterValue).pipe(debounceTime(2000))
}
Run Code Online (Sandbox Code Playgroud)

但现在它说,类型 void 上不存在管道

javascript typescript angular

4
推荐指数
2
解决办法
5169
查看次数

Rxjs反应文本输入组件

我有以下反应组件

<input className={styles.incSrchTextBox} type="text" name="search" placeholder="Search.."
   onChange={this.onChange} />


onChange(e) {
    const newText = e.target.value;
    console.log(newText);
    this.setState({ searchText: newText });
}
Run Code Online (Sandbox Code Playgroud)

我如何在rxjs上使用debounce?

rxjs reactjs

3
推荐指数
1
解决办法
4374
查看次数

为什么这个函数没有在c中递增我的变量?

所以只是在C中试验指针.

void inc(int *p){
    ++(*p);
}

int main(){
    int x = 0;
    int *p;
    *p = x;
    inc(p);
    printf("x = %i",x);
}
Run Code Online (Sandbox Code Playgroud)

为什么打印"x = 0"而不是"x = 1"?

c printing pointers function increment

2
推荐指数
1
解决办法
86
查看次数

如何显示反应式表单验证错误消息

大家好,

我正在努力为名称输入制作验证器,我只是从 angular wiki 回复了代码,但仍然无法正常工作。

你能帮我找出问题吗?

谢谢指教。

我的 HTML 代码:

  <form [formGroup]="formAlta" (ngSubmit)="addRepresentacio()">
            <div class="form-group">
              <label for="namePro">Nom</label>
              <input id="namePro" class="form-control" formControlName="namePro" placeholder="Nom del professional" required>
              <div *ngIf="namePro.invalid && (namePro.dirty || namePro.touched)" class="alert alert-danger form-danger" role="alert">

        <div *ngIf="namePro.errors.required">
            El Nom del professional es obligatori
        </div>
    </div></form>
Run Code Online (Sandbox Code Playgroud)

还有我的 TS 组件

 formAlta: FormGroup;
 ngOnInit() {
    this.formAlta = new FormGroup({
      idPro: new FormControl(),
      documentTypePro: new FormControl(),
      namePro: new FormControl('',[Validators.required]),
      rProfessional: new FormControl(this.tipusPro),
      firstSurnamePro: new FormControl(),
      secondSurnamePro: new FormControl(),
      businessNamePro: new FormControl(),
      idCli: new FormControl(), …
Run Code Online (Sandbox Code Playgroud)

typescript angular angular-reactive-forms angular5

1
推荐指数
1
解决办法
1万
查看次数

在observable中的对象数组上使用Array.filter

我想添加filter我的对象数组.我试试这个:

this.projects
      .pipe(
          map(arr => {
              console.error(arr);
              arr.filter(r => r.name == 'x')
          })
      )
      .subscribe(result => console.log('Filter results:', result))
Run Code Online (Sandbox Code Playgroud)

console.error回到我的阵列,但是当我console.log在我的subscribe我有undefined.你能帮助我吗 ?

angular

0
推荐指数
2
解决办法
71
查看次数