-1

I want to build a form reading fields from a list of values:

<form [formGroup]="fileForm" (ngSubmit)="onSubmit(fileForm.value)">
                            <section class="col col-8">
                                <div>
                                    <label *ngFor="let metadato of metadatiAbilitati" class="input">
                                        <input type="text" placeholder="{{metadato.chiave}}"
                                            [formControl]="fileForm.get(metadato.chiave)" />
                                    </label>
                                </div>
                                <!-- <label class="input">
                                    <input type="file" name="file" placeholder="seleziona file" />
                                </label> -->
                            </section>
                            <!-- <div> -->
                            <button type="submit">Aggiungi</button>
                            <!-- </div> -->
                        </form>

in component ts file I have:

constructor(private transazioneService: TransazioneService, fb: FormBuilder) { 
    this.fileInputs = [];
    let fields = {};

    this.metadatiAbilitati.forEach(m => {
      let input = this.fileForm.controls[`m.chiave`];
      this.fileInputs.push(input);
      fields[m.chiave] = m.chiave;
    });

     this.fileForm = fb.group(fields);

  }

But from browser I got this error:

enter image description here

Finally, In main module I import ReactiveFormsModule. Anyone can help me?

Vitto Lib
  • 45
  • 1
  • 9

1 Answers1

0

Finally, I have solved my problem. Chrome was caching previous changes, so I didn't see right fix.

Vitto Lib
  • 45
  • 1
  • 9