Form imports not working with rc0


#1

After changing from 2 beta.11 to 2.rc0 forms stopped working. What is the library that need to be imported to get this working?

import {FORM_DIRECTIVES, FormBuilder,  ControlGroup, Validators,Control } from '@angular/common';

ts] Module ‘“c:/myapps/ionic2-tests/mmsapp/node_modules/@angular/common/index”’ has no exported member ‘ControlGroup’.


#2

Try to replace ControlGroup with FormGroup


#3

Yes that works. But what about Control?

I use something like this in my code

(<Control>this.userDetails.controls['DisplayName']).updateValue(this.userData.DisplayName);


#4

Control is FormControl, and i did’nt achieve to update the value.
I use this little hack : i instanciate a new FormControl with the new value <FormControl> ctrl = new FormControl('new value', Validators.required);


#6

Try with this line:

import { FormBuilder, Validators, FormGroup } from ‘@angular/forms’;

There are no longer ControlGroup and Control in angular2 stable.

You can replace ControlGroup by FormGroup and Control by FormControl


#7

Yes, but now the real question is : what about update() on FormControl ?


#8

Now it is setValue

Angular2 (stable) has a lot of changes from the RC4 that was used before Ionic RC0, so take a look at api doc or change log since RC4

AbstractControl
FormControl
FormGroup


#9

check @ecureuill ’ s comments… that worked for me. Though I am still solving other compilation errors, so havent tested yet for working of the set value yet.

it should work though


#10

Yeh, errors are gone will update on working as soon as I clear other compilation errors.


#12

But i am getting this error now.

When I am trying to serve.

I am using this.
import {FormBuilder, FormGroup, Validators, FormControl } from ‘@angular/forms’;


#13

did you solve this issue?


#14

that was an issue with imports and declaration variable in the app.module.ts. I solved it by removing some providers, imports and declaration that doesnt have to be there.


#15

Thank you @ecureuill