小编art*_*uro的帖子

是否可以从 ValueChanges 交换到 (blur) 以提出请求?

我问这个是因为我开始学习一些基本的角度课程,并且我正在使用一些过滤器,在我使用 ValueChanges 输入时将请求发送到 firebase:

这是用于搜索的输入:

<input
  type="search"
  placeholder="Teclee un proveedor..."
  [formControl]="campoBusqueda"
  />
Run Code Online (Sandbox Code Playgroud)

这是我必须使用的代码ngOnInit()

this.campoBusqueda = new FormControl();
this.campoBusqueda.valueChanges.subscribe(term => {
  this.busqueda = term;
  this.cargando = true;
  if (this.busqueda.length !== 0) {
    this.proveedoresService
      .getProveedoresSearch(this.busqueda)
      .subscribe(proveedores => {
        this.proveedores = [];
        // tslint:disable-next-line: forin
        for (const id$ in proveedores) {
          const p = proveedores[id$];
          p.id$ = id$;
          this.proveedores.push(proveedores[id$]);
        }
        if (this.proveedores.length < 1 && this.busqueda.length >= 1) {
          this.noresultados = true;
          this.proveedoresService
            .getProveedores()
            .subscribe( proveedores => {
              this.proveedores = []; …
Run Code Online (Sandbox Code Playgroud)

firebase angularfire2 angular

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

标签 统计

angular ×1

angularfire2 ×1

firebase ×1