Angular 2. Set value of ControlGroup in data driven form
<p>Let's say I have this model:</p>

<pre><code>export class MyModel {
    constructor(
        public id: number,
        public name: string
    ) {}
}
</code></pre>

<p>and this ControlGroup:</p>

<pre><code>export class MyComponent {
    form: ControlGroup;
    model: MyModel;

    constructor(builder: FormBuilder) {
        this.form = this.builder({
            'id' : [''],
            'name' : ['']
        })
    }
}
</code></pre>

<p>To get form's data I can simply do that (if field names match):</p>

<pre><code>this.model = this.form.value;
</code></pre>

<p>But how can I set form's value in the same manner?</p>

<pre><code>something like: this.form.value = model;
</code></pre>

<p>Getting the following error:
Cannot set property value of #&lt;AbstractControl&gt; which has only a getter</p>

<p>Thank you!</p>

<p><strong>UPD</strong>: Based on Günter Zöchbauer's suggestion below I ended up with that helper method:</p>

<pre><code>setFormValues(form: ControlGroup, model: any) {

    for(var key in model) {
        var ctrl = (&lt;Control&gt;form.controls[key]);
        if ( ctrl != undefined )
            ctrl.updateValue(model[key]);
    }
}
</code></pre>