Has anyone encountered this error message before? TypeError: Cannot create property 'validator' on string 'control'"
import { Component, ChangeDetectionStrategy, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { DataStorageService, FieldConfig, ImportType } from '../../../../services/datastorage.service';
import { ReactiveFormsModule, FormGroup, FormArray, FormControl } from '@angular/forms';
import * as Papa from 'papaparse';
@Component({
selector: 'field-analysis',
templateUrl: './field-analysis.component.html'
})
export class FieldAnalysisComponent implements OnInit {
fieldsGroup;
ngOnInit() {
this.fieldsGroup = new FormGroup({ fieldset: new FormArray([new FormControl(''), new FormControl('')]) });
}
}
This is how the template has been structured:
<h2 >Field Definition</h2>
<form formGroup="fieldsGroup" novalidate>
<input *ngFor="let control of fieldsGroup.controls['fieldset'].controls" formControl="control">
</form>