in Angular2 how to know when ANY form input field lost focus

Discussão em 'Angular' iniciado por born2net, Outubro 9, 2024.

  1. born2net

    born2net Guest

    In Angular2 how to know when ANY input field has lost focus..! If I use observables on the form:

    form.valueChange.subscribe...


    wont work since I really want to know when a field lost it's blur (focus) so I can update my store (if I update the store before losing focus, my cursor on a text input gets moved to the end, since the data gets swapped which is weird looking)

    of course I can also add (change)="" on each input, but I have a lot of'em...

    I was thinking something of the sorts of:

    this.form.valueChanges.debounceTime(1000).subscribe((changes:any) => {
    if (this.form.dirty){
    this.appStore.dispatch(this.resellerAction.updateResellerInfo(changes))
    }
    });


    but the problem is that the dirty remains dirty, so it stuck in an everlasting loop of change detections...

    tx

    Sean

    Continue reading...

Compartilhe esta Página