小编Osc*_*tos的帖子

*ng如果不工作,只有当离子页面上的东西发生变化时

我在使用“* ngIf”时遇到问题,显然它什么也不做,但是当离子页面上的某些内容发生变化时,例如,当单击输入或屏幕从纵向变为横向时,键盘会显示它显示更改(隐藏/显示) 我做了一个简单的例子:

页面.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>
Run Code Online (Sandbox Code Playgroud)

页面.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);
 }
}
Run Code Online (Sandbox Code Playgroud)

我不知道为什么会这样,一些想法?谢谢!

angular-ng-if ionic-framework angular

2
推荐指数
1
解决办法
6453
查看次数

标签 统计

angular ×1

angular-ng-if ×1

ionic-framework ×1