Checkbox is not unchecked by default

 <form [formGroup] = "myForm">
 <ion-item>
              <ion-label>language</ion-label>
              <ion-checkbox formControlName = "language"  [checked]="unchecked"></ion-checkbox>
            </ion-item>
      </form>
          <button ion-button block tappable  >Submit</button>

export class TestdataPage {
language : boolean;
  myForm : FormGroup;
  constructor(public navCtrl: NavController, public navParams: NavParams, private fb:FormBuilder) {
    this.crateForm();

  }
  crateForm(){
    this.myForm = this.fb.group({
      language : [Validators.nullValidator]
    });
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad TestdataPage');
  }

}

> when i execute above code the check box is coming as checked by default. i don't know why?


Do not bind the checked property if you are using reactive forms. Simply set the value of the bound FormControl.

Actually it’s worked when i made simple change.
i modify
language : [false]
Thanks for the support

1 Like