Angular duplicating inputs with ngFor

Asked

Viewed 25 times

0

In this app I want it to only return the value of the quantity in the input if the profile name is equal to the profile name of the data flock , but the angle is doing the following: It runs the ngFor once to be able to find which profile is equal to the first , and then rotate again to see which profile is equal to the second , thus :

inserir a descrição da imagem aqui

I wish someone would help me make it run only once ngFor and return with the right input , comparing the first and second profiles at once. Thank you for your attention.

Html code :

<ng-container *ngFor='let i of Resultado_calculo_Orcamento.Perfis'>
                  <input *ngIf='i.perfil == perfil.perfil ; else elseBlock' 
                name="" type="text" placeholder="" class="grid_amount-input perfisQuantidade" value="{{i.quantidade}}" #valor 
                (input)="valueChange($event)" value="{{i.quantidade}}" #valor>
                </ng-container>
                <ng-template #elseBlock>
                  <input
                  name="" type="text" placeholder="" class="grid_amount-input perfisQuantidade" value="0" #valor 
                  (input)="valueChange($event)" value="0" #valor>
                </ng-template>

Code in the Component.ts :

Perfis : [{perfil : perfilMenor , quantidade : quantidadePerfilMenor},
          {perfil : perfilMaior , quantidade : quantidadePerfilMaior}],
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.