ionic3 - 值更改后视图未更新

时间:2018-03-31 20:12:34

标签: javascript ionic-framework

更改滑块的值后,有关滑块值的显示不会更新 这是我的代码: HTML:

  <ion-range min="1" max="24" pin= "true" [(ngModel)]="time">
    <p range-left>1</p>
    <p range-right>24</p>
  </ion-range>
  <p>{{purchasePrice}}</p>

TS:

 time : number 
 purchasePrice = 10 * this.time

1 个答案:

答案 0 :(得分:0)

需要使用(ionChange)并更新该函数中的值

<ion-range min="1" max="24" pin= "true" (ionChange)="updateTime()" [(ngModel)]="time">
        <p range-left>1</p>
        <p range-right>24</p>
      </ion-range>
      <p>{{purchasePrice}}</p>

控制器代码:

export class HomePage {
time : number ;
 purchasePrice = 0;
  constructor(public navCtrl: NavController) {

  }

  updateTime(){
    this.purchasePrice =  10 * this.time;
  }

}

进行实时检查demo here