I'm building reactive form with angular 5, I'm trying to add select with option from list, but the list not present in the html page. I saw some similar questions and tried the suggested answers but without succsses, what am i doing wrong?
ts:
firstQuestionnaire: FormGroup;
yearsCurrentHome: string [] = ['1','2','3','4','5+'];
default: string = '1';
constructor(private formBuilder: FormBuilder) {
this.firstQuestionnaire=this.createFormGroup();
this.firstQuestionnaire.controls['yearsInCurrentHome'].setValue(this.default, {onlySelf: true});
}
createFormGroup() {
return new FormGroup({
yearsInCurrentHome: new FormControl(null)
});
}
HTML:
<div class="question">
<label>YEARS: </label>
<select formControlName="yearsInCurrentHome">
<option *ngFor="let year of yearsCurrentHome" [ngValue]="year"> {{year}}
</option>
</select>
</div>
thanks