0
votes

I have a big problem in my project. I'm using a *ngIf that work only in android platform. In iOS platform doesn't work.

I have this code in HTML:

<GridLayout columns ="auto, auto" rows="*" (tap)="open()">
  <StackLayout col="0" row ="0">
     <label text="SomethingText"></label>
  </StackLayout>
  <StackLayout col="1" row ="0" *ngIf="sub">
     <label text="Right"></label>
  </StackLayout>
  <StackLayout col="1" row ="0" *ngIf="!sub">
    <label text="Bottom"></label>
  </StackLayout>
</GridLayout>

In TS I have:

sub: boolean = false;

public open() {
   this.sub= !this.sub;
    console.log('value',this.sub)
    }

When I click function in view show not correct, show empty, Right,Bottom,Bottom,etc.

But console in function show correct true , false in each click.

Please, can you ask me any idea how to solution this problem?

1
Can you share a Playground sample where the issue can be reproduced? - Manoj

1 Answers

0
votes

best way to implement this is to use ngif/else instead of having 2 ngif blocks.

<StackLayout col="1" row ="0"  *ngIf="sub === true; else elseBlock"><label text="Right"></label>
  </StackLayout>
<ng-template #elseBlock> <StackLayout col="1" row ="0">
    <label text="Bottom"></label>
  </StackLayout></ng-template>

For further reading, you can refer here.