离子无线电群ng模型选择

时间:2019-02-02 18:31:03

标签: angular radio-group ionic4

我想要一个离子无线电元件上实现ngModel用于改变单元,用于我的应用程序。一切都很好,但是当选择选项一并选择选项拖曳时,他堆在选项一上! 。我想让用户只选择选项

html:

<ion-list>
    <ion-radio-group>
      <ion-list-header>
        Unit Fuel
      </ion-list-header>

      <ion-item>
        <ion-label>LBS</ion-label>
        <ion-radio value="LBS" [(ngModel)]="Fuel_lbs"></ion-radio>
      </ion-item>

      <ion-item>
        <ion-label>KG</ion-label>
        <ion-radio value="KG" [(ngModel)]="Fuel_kg"></ion-radio>
      </ion-item>

    </ion-radio-group>
  </ion-list> 

我的操作代码可以对磅和公斤进行数学运算

    public Fuel_kg: boolean = false; 
      public Fuel_lbs: boolean = false; 

      public object: any;
      constructor(public http: HTTP,public https: HttpClient,public alertCtrl:AlertController) {

      }
 async addThemFunction () {

  if (this.Fuelunit_lbs ==true) {
    let  firstNumber = this.firstNumber ? parseFloat(this.firstNumber) : 0 ;
    let  mainfuellbs = this.mainfuellbs ? parseFloat(this.mainfuellbs) : 2200 ;
    if(firstNumber==0){
      let alert = await this.alertCtrl.create({
        header: 'Alert',
        message: 'Pleas Enter value !',
          buttons: ['OK']
      });
      await alert.present();

  }else{
    this.totallbs =firstNumber * mainfuellbs;
    this.clickMessageforlbs='This flight is around '+ firstNumber + ' nm , so you need '

  }
  console.log("clicked!");

  }else if (this.Fuel_kg==true) {
    let  firstNumber = this.firstNumber ? parseFloat(this.firstNumber) : 0 ;
    let  mainfuelkg = this.mainfuelkg ? parseFloat(this.mainfuelkg) : 1000 ;
    if(firstNumber==0){
      let alert = await this.alertCtrl.create({
        header: 'Alert',
        message: 'Pleas Enter value !',
          buttons: ['OK']
      });
      await alert.present();

  }else{
    this.totallbs =firstNumber * mainfuelkg;
    this.clickMessageforkg='This flight is around '+ firstNumber + ' nm , so you need '

  }
  console.log("clicked!");
  }

  }

使用ngmodel无法选择一个选择

enter image description here

与出ngmodel

enter image description here

ionic doc radio group

请帮忙吗?

0 个答案:

没有答案