收到错误“ TypeError:无法在字符串'control'上创建属性'validator'”

汤米琼斯

我收到错误消息:TypeError:无法在字符串“ control”上创建属性“ validator””

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

  }

}

模板看起来像这样。

<h2 >Field Definition</h2>
<form formGroup="fieldsGroup" novalidate>


<input *ngFor="let control of fieldsGroup.controls['fieldset'].controls" formControl="control">
</form>
yurzui

已将字符串传递fieldsGroupFormGroupDirective您应该FormGroup改为传递实例:

[formGroup]="fieldsGroup"

而且FormControlDirective也希望FormControl实例

[formControl]="control"

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

TypeError:无法在setUpControl的字符串“ [email protected]”上创建属性“ validator”

无法使用组件工厂在字符串“ userForm”上创建属性“ validator”

类型错误:无法在字符串 'a' 上创建属性 'style'

Angular TypeError:无法在字符串''上创建属性

TypeError:无法在字符串“ /:id”上创建属性“ next”

错误TypeError:“无法在“ signUpForm”上分配给属性“ validator”:不是对象”

JS错误,未捕获的TypeError:无法读取未定义的属性“子字符串”

未被捕获的TypeError:无法在字符串'上创建属性'guid'

未捕获的TypeError:无法在字符串“ wtd_background_image”上创建属性“ style”

未被捕获的TypeError:无法在字符串“”上创建属性“ empFirstName”

nodejs 收到错误 TypeError:无法读取未定义的属性“then”

express-openapi-validator:错误:TypeError:无法读取未定义的属性“模式”

我在我的React项目上收到此错误“ TypeError:无法读取未定义的属性'map'”

无法在字符串 '' 上创建属性 'fillColor'

尝试根据逗号分割字符串,而不会在空格上收到错误

尝试操作字符串时在 codewars 上收到退出代码错误

无法在Chrome扩展程序中创建通知。收到未捕获的TypeError:无法读取未定义错误的属性“创建”

迭代对象的通用属性,验证它是对象的属性而不是任何字符串(我从编译器收到错误)

我在显示地图图钉时收到错误Uncaught InvalidValueError:setIcon:在属性url中:不是字符串

为什么在字符串对象上出现属性错误?

收到此错误:无法读取未定义的属性“长度”

我收到错误消息:无法读取null的属性“ push”

收到错误“无法读取未定义的属性'模板'”

条带实现收到错误无法读取null的属性'addEventListener'

收到此错误:无法读取未定义的属性“0”

收到以下错误无法读取未定义的属性“startsWith”

无法在Web Api 2中的BadRequest上收到错误消息

收到太长的字符串错误错误414

gulp Iconify任务引发错误TypeError:路径必须是字符串。收到假