0
votes

I'm updating my project from Ionic Beta to Ionic RC, and I'm getting this error:

Module '"/home/xxx/Desktop/myApp/node_modules/@angular/common/index"' has no exported member 'Control' 
L1:  import {Control} from '@angular/common';

How do I import correctly Control member ?

Can you provide a page (if it exists) with Ionic RC members and their relative module?

For your information when I do ionic info I get:

Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.1
Ionic CLI Version: 2.1.1
Ionic App Lib Version: 2.1.1
Ionic App Scripts Version: 0.0.36
OS: Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS 
Node Version: v4.2.6
1
What control are you trying to import? As far as I know, Angular 2 does not have (and hasn't for quite some time) had a Control export. As far as what is in @angular/common the API docs on their site has the information /common specifically - Dave V

1 Answers

0
votes

Everything related to forms will be in @anuglar/forms.

First need to @NgModule.imports: [ ReactiveFormsModule ] to get all the directives.

Instead of Control, you'll want to use FormControl. There's also FormGroup, and also FormBuilder that you can inject.

For the directives, you can either use [formControl] to handle individual FormControl. Or you can use formControlName along with FormGroup

For example

@Component({
  template: `
    <form [formGroup]="form">
      <input type="text" formControlName="firstName"  />
      <input type="text" formControlName="lastName"  />
    </form>
  `
}) 
class SomeComponent {
  form: FormGroup;

  constructor(builder: FormBuilder) {
    this.form = builder.group({
      'firstName': '',
      'lastName': ''
    })
  }
}

See Also: