Put an IF inside the HTML text with ionic / firebase

2

So I have a problem with my code, I would like to do an if within my html code from ionic, 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>

Given that within my database there is a search for this node, I would like the statement to be true if it displays all fields that are larger than 17, but I have two errors, the first is that if the statement is true it is shown to me "personDiaCriado" and not the value that is in the bank, and second that if it is false, it is showing me an empty option, I would like it not to appear.

    
asked by anonymous 05.12.2018 / 22:54

1 answer

2

Try to do something like this.

<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 this should solve.

Obs : Your first error is that person.DiaCriado is between '' , just take, the second will actually display a select with value ' ' , since it was the condition placed , I really think the best solution is if , in case you would use *ngIf

    
05.12.2018 / 23:11