I'm having problems with "*ngIf", aparently it does nothing but when something change on the ionic page, for example, the keyboard shows when click on input or the sceen change from portrait to landscape it shows the change (hide/show) I did a simple example:
page.html
<ion-header> <ion-navbar> <ion-title>Page</ion-title> </ion-navbar> </ion-header> <ion-content> <div *ngIf="loadingVisible"> <img src="assets/imgs/example.jpg" alt=""> </div> <button ion-button (click)='showorhide();'>click to show or hide</button> </ion-content> page.ts
import { Component } from '@angular/core'; import { NavController} from 'ionic-angular'; @IonicPage() @Component({ selector: 'page-new-table', templateUrl: 'new-table.html', }) export class NewTablePage { public loadingVisible:boolean = false; constructor(public navCtrl: NavController){ } showorhide(){ this.loadingVisible = this.loadingVisible ? false : true; console.log(this.loadingVisible); } } I don't know why this happend, some ideas? Thank you!
this.loadingVisible = this.loadingVisible ? false : true;can be shortened asthis.loadingVisible = !this.loadingVisiblechangeDetectorRef.detectChanges()?