How to make a for on Ionic?


#1

Hey guys i’m new with Ionic and I’ve got lot of doubts. In my project, I have requests and each request has an array of proposals. But when I pull the list from database I just wanna show the proposes who are ‘Winner’ and their requests are ‘Finished’, You guys got it? I’ll show the code.

Html`

     <ion-segment-button value="third" (click)="getProposal('Winner')">
        Aceitas
      </ion-segment-button>

TypeScript

  getProposals(status: string) {

    if (status === 'Winner') {
      this.requestService.getProposalsPartner(this.user.email, status).then( resposta => {
            let proposalsWinner = resposta;
            for (let i in proposalsWinner) {
              if (proposalsWinner[i].request.status != 'Finished') {
                this.proposals = resposta;
              }              
            }
        })

    } else {
          this.requestService.getProposalsPartner(this.user.email, status).then( resposta => {
          this.proposals = resposta;
        })  
    }

  }

So I’ve tried to make a for and only put on the list the proposals that follow the pattern I referred to. I’ve tested and it isnt working the way I wanted to. What’s wrong on my code?


#2

some considerations: I’m using ‘Enum’ on Java and I now I could use another status for proposals named ‘Finished’. But I wanna understand how it works using for, thanks for all las (: