Actually I am stuck with an issue when using checkbox in ionic2.
I am using checkbox as:
<ion-item>
<ion-label>Agree</ion-label>
<ion-checkbox color="dark" id="agree" name='agree' class="form-control" formControlName="agree" [checked]="false" ></ion-checkbox>
</ion-item>
In .ts i am fetching its value as :
console.log(this.timelogForm.controls['agree'].value);
I want it to be unchecked initially.
My issues are :
on using formControlName="agree" it is checked ..
I get its value in .ts if it is once clicked but I want if it's not clicked on submit I get false and if checked I get true..
Any help please
I resolved it on my own hope it helps someone..
I set its value as false like:
this.logForm = formBuilder.group({
'agree': ['false'],
});
Hope it helps someone.