I have following array:
testArray=[1,2,3,4]
and the follwoinh HTML code:
<div >
<select>
<option *ngFor="let obj of testArray"
name="mission"
formControlName="mission"
(click)="onMissionClick(mission)"
[value]="obj"
>
{{obj}}
</option>
</select>
</div>
the output is a dropdown list with only the first tow value of the testArray which are : 1 , 2. Then I got the following error:
BasicInfoDPComponent.html:39 ERROR Error: No value accessor for form control with name: 'mission'
at _throwError (forms.js:1591)
at setUpControl (forms.js:1501)
at FormGroupDirective.push../node_modules/@angular/forms/fesm5/forms.js.FormGroupDirective.addControl (forms.js:4037)
at FormControlName.push../node_modules/@angular/forms/fesm5/forms.js.FormControlName._setUpControl (forms.js:4542)
at FormControlName.push../node_modules/@angular/forms/fesm5/forms.js.FormControlName.ngOnChanges (forms.js:4492)
at checkAndUpdateDirectiveInline (core.js:8941)
at checkAndUpdateNodeInline (core.js:10209)
at checkAndUpdateNode (core.js:10171)
at debugCheckAndUpdateNode (core.js:10804)
at debugCheckDirectivesFn (core.js:10764)
NOTE: as you may noticed I need to put the drop down in a form, Out of form works fine.