得到错误" TypeError:无法创建属性'验证器'在字符串'控制'"

时间:2017-07-21 03:44:12

标签: angular typescript

我收到错误: TypeError:无法创建属性'验证器'在字符串'控制'"

CNContactPickerViewController

模板看起来像这样。

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('')]) });

  }

}

1 个答案:

答案 0 :(得分:4)

您将字符串fieldsGroup传递给 FormGroupDirective 。您应该通过FormGroup实例:

[formGroup]="fieldsGroup"

FormControlDirective 也需要FormControl个实例

[formControl]="control"