How to enable/disable radio-group programatically?


#1

Hi everyone! i’m having this issue. I just can’t set a radio-group to enabled / disabled programatically.

The html code below:

          <ion-list radio-group [formControl]="dataForm.controls['has_another_house']" (ionChange)="checkHasAnotherHouse()">
            <ion-list-header>
              Has another house?
            </ion-list-header>
            <ion-item>
              <ion-label>Yes</ion-label>
              <ion-radio value="1"></ion-radio>
            </ion-item>
            <ion-item>
              <ion-label>No</ion-label>
              <ion-radio value="0"></ion-radio>
            </ion-item>       
          </ion-list>

          <ion-list radio-group formControlName="dataForm.controls['another_house']">
            <ion-list-header>
              If yes, is it in the same city?
            </ion-list-header>
            <ion-item>
              <ion-label>Yes</ion-label>
              <ion-radio value="1"></ion-radio>
            </ion-item>
            <ion-item>
              <ion-label>No</ion-label>
              <ion-radio value="1"></ion-radio>
            </ion-item>          
          </ion-list>

The control bellow:

  checHasAnotherHousel() {

    if (this.dataForm.controls['has_another_house'].value != null &&
        this.dataForm.controls['has_another_house'].value == '1') {
      this.dataForm.controls['another_house'].enable();
    } else {
      this.dataForm.controls['another_house'].disable();
    }
  }

In the other hand, if i do the same test with a ion-input insted of a radio-group it works i don’t know why… Could someone help me in this issue?

Thanks in advance!