How to iterate variable at angular every time a certain condition is met?

Asked

Viewed 65 times

0

     <div *ngFor="let elemento of team.elementos" class="{{elemento.colunas}}">
            <div *ngIf="(elemento.dataPublicacao < hoje) && (elemento.dataValidade > hoje)">
              <span>{{qtdIntegrantes}}</span>
              <div *ngIf="qtdIntegrantes == 1">
                <div class="team-member">
                  <img class="mx-auto rounded-circle" src="{{getCampoElem(elemento, 'img')}}" alt="">
                  <h4>{{getCampoElem(elemento, 'nome')}}</h4>
                  <p style="margin-bottom:0px" class="text-muted">{{getCampoElem(elemento, 'posto')}}</p>
                  <p style="margin-bottom:0px" class="text-muted numdesk">{{getCampoElem(elemento, 'telf')}}</p>
                  <a class="text-muted nummob"
                    href="{{getCampoElem(elemento, 'telfhref')}}">{{getCampoElem(elemento, 'telf')}}</a>
                </div>
              </div>
           </div>
     </div>

Basically every time the condition of ngIf is met, the qtdIntegrantes should increase, there is some way to do this in Angular?

  • Better to do this logic in typescript than in ngIf

  • why not do no ts?

  • What would I call the function on ts?

  • the ngIf is only a render filter based on the entered condition. If you want to change the variable value qtdIntegrantes you can do a for on ts that changes the variable value.

No answers

Browser other questions tagged

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