0

I'm trying to create multiple instance of the same form in an Ionic App in the following way:

<ion-card *ngFor="let i of times">
    <form #f="ngForm" (ngSubmit)="updateTime(i['id'])">
      <ion-item>
        <ion-label><b>Dia: </b></ion-label>
        <ion-select>
          <ion-option *ngFor="let k of dias" [value]="k.id" [selected]="k.dia == i.diaSemana">{{k.dia}}</ion-option>
        </ion-select>
      </ion-item>
      <div class="class">
        <ion-item>
          <ion-label><b>Hora Inicio:</b></ion-label>
          <ion-datetime displayFormat="HH:mm" pickerFormat="HH mm" [(ngModel)]="i['inicio']" name="inicio" required></ion-datetime>
        </ion-item>
        <ion-item>
          <ion-label><b>Hora Fin:</b></ion-label>
          <ion-datetime displayFormat="HH:mm" pickerFormat="HH mm" [(ngModel)]="i['fin']" name="fin" required></ion-datetime>
        </ion-item>
      </div>
    </form>
    <br>
    <button class="submitButton" ion-button type="submit" block>Modificar Horario</button>
  </ion-card>

However, when I press on the Submit button the updateTime() method is not trigger. After some research, all answers lead to ngFor inside a Form which is the opposite of what I'm looking for.

So the question is, How can I create multiple copies of a form using the ngFor.

Esteban Sierra
  • 61
  • 1
  • 10
  • Did you try the suggestions found in [this post](https://stackoverflow.com/q/38054631/1009922)? [This one](https://stackoverflow.com/a/38054632/1009922), in particular, does not rely on an `id`. It would be `(click)="f.ngSubmit.emit()"`. – ConnorsFan Oct 10 '18 at 20:47

1 Answers1

0

use (submit) instead of (ngSubmit)

Sunil Singh
  • 11,001
  • 2
  • 27
  • 48