Ionic formControlName and ngIf don't work together

75 views Asked by At

I've made a list that will only be shown by a true condition. Inside that list I have a input with formControlName, it works fine without the ngIf="indPermiteDesconto == 1" on ionList. It's like formControlName gets lost, it can't find the form value. When I remove it, it works fine again. Any ideas what's happening? I have tried to put a form as asked on some answers here, but didn't work either.

<form [formGroup]="form">
    <ion-list *ngIf="indPermiteDesconto == 1">
      <ion-item>
        <h4>Total:</h4>
        <span item-end>
          {{ produto?.moedaVenda }}
          {{ vlTotalProduto | unoDecimal }}
        </span>
      </ion-item>
      <ion-item>
        <ion-label fixed>Desconto %</ion-label>

        <ion-input
          type="number"
          value="0"
          max="100"
          min="0"
          (change)="recalcularTotais()"
          formControlName="percDesconto"
        ></ion-input>
      </ion-item>
      <ion-item>
        <h4>Desconto Valor</h4>
        <span item-end>
          {{ produto?.moedaVenda }}
          {{ vlDesconto | unoDecimal }}
        </span>
      </ion-item>
      <ion-item>
        <h4>Valor Total c/ Desconto</h4>
        <span item-end>
          {{ produto?.moedaVenda }}
          {{ vlFinalProduto | unoDecimal }}
        </span>
      </ion-item>
    </ion-list>
0

There are 0 answers