I have this plunker. I am creating form components dynamically, based on model
(defined in app.ts
), and cannot add
formControlName = \"n
To keep form value in sync with your custom model i would subscribe to control.valueChanges
let control = new FormControl(this.model.data);
control.valueChanges.subscribe(x => {
this.model.data = x;
});
this.form.addControl(this.model.name, control);
to keep in sync form model and view i would bind FormControl
to reactive directive i.e. formControl
datepicker.component.html
<input [formControl]="form.get(model.name)">
Modified Plunker