Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74765

Angular Detect change on html input element or trigger it automatically

$
0
0

I want to get the value of an input element once it changes. The value is not typed by the user. I got it from a source and bind it with [(ngModel)] or just [value]. I have tried everything. But I still got nothing. I even search on how to trigger an event manually. if some of you can help me, I would be grateful

My code: I have tried various things. But this is the one that seems to work. But this instructions in the subscribe method was executed twice

this.maxGroup$ = this.reponseService.getMaxGroupe();


    this.maxGroup$
    .subscribe((rep: MaxGroup) => {
      if(rep){
      this.maxGroupe = rep;
      this.max = rep.valeur;
      this.questions.forEach(q => {
        let r = new Reponse()
        r.QuestionId = q.Id.toString();
        r.Question = q;
        r.Groupe = rep.valeur;
        this.reponses.push(r);
      });
    }
      this.max++;
      this.maxGroupe.valeur = this.max;
      let ref = this.reponseService.createMax(this.maxGroupe);
      this.reponseService.deleteMax(this.idMax);

    });

In my service:

return this.db.list('/maxGroup').snapshotChanges().map(snapshots => {
  return snapshots.map(c => ({ key: c.payload.key, ...(c.payload.val()) as {} }));
});

In my template:

<div *ngFor="let m of maxGroup$ | async">
<input #KeyMax type="text" id="keyMax" [(ngModel)]="m.key" [value]="m.key" (change)="keyChange()"/>


Viewing all articles
Browse latest Browse all 74765

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>