Anna
Anna

Reputation: 1627

How to update control inside ControlGroup Angular 2

any one have a plnkr or a simple example on how to updateValue Control inside a ControlGroup (ANGULAR 2 BETA 7) ??

i want to change the value of my Zipcode on my adress controlGroup, this is what i've tried:

(<Control>this.form.controls['address'].zip.label).updateValue("3000");

&

this.form.controls.address.zip.label.updateValue("3000");

neither did work, any one have a hint ?

here is how i creat the form :

this.form = fb.group({
           adress: fb.group({
            zip: fb.group({
                label: []
            })
        });

Upvotes: 1

Views: 212

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 658027

I think the easiest way is to use find:

(<Control>this.form.find('adress/zip/label')).updateValue("‌​3000");

Upvotes: 1

Related Questions