Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2: Error - Property 'updateValue' does not exist on type 'AbstractControl'

I've created a ControlGroup theForm using FormBuilder.

When I tried to update value of a control like this

this.theForm.find('MainImageId').updateValue( id, true, true);

It worked fine but WebStorm shows an error saying

Error:(148, 24) TS2339: Property 'updateValue' does not exist on type 'AbstractControl'.

What am I doing wrong? and why does it work?

like image 313
Ankit Singh Avatar asked Jan 08 '16 05:01

Ankit Singh


1 Answers

According to Typescript casting object's property I guess this should fix it

find is now get (>=RC.5)

   (<Control> this.theForm.find('MainImageId')) .updateValue( id, {onlySelf:true, emitEvent:true});

   // (<Control> this.theForm.find('MainImageId')) .updateValue( id, {onlySelf:true, emitEvent:true});

Edit: Optional parameters are supplied as an Object in second parameter.

like image 126
Günter Zöchbauer Avatar answered Sep 28 '22 07:09

Günter Zöchbauer