A
A
andreys752019-09-03 19:10:25
Angular
andreys75, 2019-09-03 19:10:25

How to track the change of @Input variable in the component?

Good afternoon,
There is a component, it has an input parameter In the component, the elements of this array are associated with the form like this
@Input() SafetyIncidents: Array<SafetyIncident>;

<mat-form-field class="col-md-1">
        <input name=SafetyIncidentImpactId [(ngModel)]="Incident.ImpactId" matInput placeholder="Impact ID">
</mat-form-field>

But new array elements can also be added through the code:
addSafetySection() {
      this.SafetyIncidents.push(new SafetyIncident());
    //  console.log("add new incedent");
  }

How to track changes to the SafetyIncidents array?
Alas, I could not find an intelligible example with either subject or observable. The problem is that the form is related specifically to SafetyIncidents, which is not an observable.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2019-09-03
@Xuxicheta

everything is in the documentation
https://angular.io/guide/component-interaction#int...
Oh, and more

addSafetySection() {
      this.SafetyIncidents = this.SafetyIncidents.concat(new SafetyIncident());
    //  console.log("add new incedent");
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question