Marcos J.C Kichel
Marcos J.C Kichel

Reputation: 7219

Angular 2: md-select along with reactive forms throws error

Trying to get those two working along, I am using reactive forms all over my application, even on this same component, so I believe it has nothing to do with angular reactive forms dependencies.

template:

<md-select placeholder="Tipo da Conta" formControlName="tipoDaContaBancaria">
  <md-option *ngFor="let opt of tiposConta"
          [value]="opt.value">{{opt.label}}</md-option>
</md-select>

component:

@Component({
  moduleId: module.id,
  selector: 'entidade-form.component.ts',
  templateUrl: 'entidade-form.component.html',
  styleUrls: ['entidade-form.component.css']
})
export class EntidadeFormComponent implements OnInit {

  form: FormGroup;
  tiposConta = [{value: 'CONTA_CORRENTE', label: 'Conta Corrente'}, {value: 'POUPANCA', label: 'Poupança'}];

  ngOnInit() {
    this.form = this.fb.group({
      tipoDaContaBancaria: ['']
    });
  }
}

error: No value accessor for form control with name: 'tipoDaContaBancaria'

Upvotes: 0

Views: 900

Answers (1)

Marcos J.C Kichel
Marcos J.C Kichel

Reputation: 7219

Importing MdSelectModuleinside Module fixes the problem

Upvotes: 1

Related Questions