*ngIf doesn't show DIV in ionic view on iOS


#1

I have a problem with ngIf in ionic view.

i create a simple button that i show and hide a div

this is my html code

<ion-header>
  <ion-navbar>
    <button ion-button menuToggle>
      <ion-icon name="menu"></ion-icon>
    </button>
    <ion-title>Costa Eventi</ion-title>
    <button ion-button class="calendar-icon">
      <ion-icon name="grid" *ngIf="default" (click)="showCalendar()"></ion-icon>
      <ion-icon name="list-box" *ngIf="!default" (click)="showList()"></ion-icon>
    </button>
  </ion-navbar>
</ion-header>


<ion-content>
  <div class="container" *ngIf="default">
    <ion-tabs tabsPlacement="bottom" selectedIndex="1">
      <ion-tab [root]="tab1Root" tabTitle="Next Week" tabIcon="ios-calendar"></ion-tab>
      <ion-tab [root]="tab2Root" tabTitle="Today" tabIcon="ios-clock"></ion-tab>
      <ion-tab [root]="tab3Root" tabTitle="Next Month" tabIcon="ios-calendar"></ion-tab>
    </ion-tabs>
  </div>

  <div *ngIf="!default">
    <p> PROVA</p>
  </div>

</ion-content>

in ts i create a two simple functions

  showCalendar() {
    this.default = false;
  }

  showList() {
    this.default = true;
  }

It works in ionic serve and on emulate android but doesn’t work io ionic view on ios

why?

Thank You!


#2

Did you declare the variable before using it inside showCalendar and showList?


#3

Yes i declare in exportClassPage
public default: any


#4

Why would you declare it type any if you know it’s a boolean? but I suppose that shouldn’t be an issue. Do you see anything in your logs while debugging it on the device?


#5

is possibile to view log in ionic view?


#6

Should be: https://docs.ionic.io/tools/developer/#remote-debugging


#7

Hi guys, I’ve got the same problem only on iOS… have you found out how to deal with it ?


#8

Hi , i too have the same problem…have you found the solution?