Place an IF inside HTML text with Ionic/firebase

Asked

Viewed 120 times

2

so I’m having a problem with my code, I’d like to do an if inside my Ionic html code, something like:

<ion-item class="camposSelect" *ngFor="let person of profiles" >
        <ion-label color="primary">Dia: </ion-label>
        <ion-select [(ngModel)]="ficha.teste" required >
            <ion-option [value]="person.DiaCriado">{{person.DiaCriado >= 17 ? 'person.DiaCriado' : ' '}}</ion-option>


        </ion-select>
    </ion-item>

Since inside my bank there is the research of this Ode, I would like that if the statement were true it would display all fields that are larger than 17, but I have two errors, the first is that if the statement is true it is shown me "person.Diacreated" and not the amount that’s in the bank, and according to that if it’s fake, it’s showing me an empty option, I wish it didn’t even show up.

1 answer

0

Try to do something like.

<ion-item class="camposSelect" *ngFor="let person of profiles" >
    <ion-label color="primary">Dia: </ion-label>
    <ion-select [(ngModel)]="ficha.teste" required >
        <ion-option [value]="person.DiaCriado" *ngIf="person.DiaCriado >= 17">
          {{ person.DiaCriado }}
        </ion-option>
    </ion-select>
</ion-item>

I think that should do it.

Obs: Your first mistake is that the person.DiaCriado is among '', just take off, the second will actually display a select worthwhile ' ', because it was the condition put, I really think the best solution is the if, in case you would use the *ngIf

  • Thank you very much, the answer served perfectly.

  • In need, we are there :D

Browser other questions tagged

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