2
<wj-combo-box 
    [itemsSource]="years" 
    formControlName="modelYear" 
    class="form-control" [isEditable]="false" 
    [isDisabled]="isEditVehicle"
    placeholder="Select model year">
</wj-combo-box>

I'm tried the above code, but i'm getting error when submiting the form.

ERROR Error: There is no FormControl instance attached to form control element with name: 'modelYear' at _throwError

1 Answers1

0

Your Combo control should be a child of a form group object:

<form [formGroup]="vehicleForm">
  <wj-combo-box 
     [itemsSource]="years" 
     formControlName="modelYear" 
     class="form-control" [isEditable]="false" 
     [isDisabled]="isEditVehicle"
     placeholder="Select model year">
  </wj-combo-box>
</form>

In the component code constructor, you need to create the form group object like this:

constructor(private fb: FormBuilder) {
  this.vehicleForm = this.fb.group({
    modelYear: null,    // or feel free to pre-populate it
  });
}

Please let me know if I miss something.

Babak
  • 1,274
  • 15
  • 18