2017-07-21 19 views
2
「はTypeErrorを 『コントロール』プロパティを作成できません、文字列の 『バリ』」

プロパティを作成できません「バリ」の文字列の「コントロール」」エラーの取得 はTypeError:::私はエラーを取得しています

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> 

答えて

1

あなたはFormGroupDirectiveに文字列fieldsGroupを通過したあなたが代わりにFormGroupインスタンスを渡す必要があります。。

[formGroup]="fieldsGroup" 

そしてFormControlDirectiveFormControlインスタンス

[formControl]="control" 
を期待します
関連する問題