I have created a checkbox in my project. When the app is loaded the initial value of the checkbox is checked. How to make its initial value as unchecked.
kindly show me your code
try this
<ion-checkbox slot="end" ></ion-checkbox>
<ion-checkbox slot="end" checked="true"></ion-checkbox>
<ion-checkbox slot="end" checked="false"></ion-checkbox>
show me your checkbox html code
`
DECLARATION FORM <p>
<ion-checkbox slot="end" checked="false" ngModel name="checking"></ion-checkbox> I hereby declare that, I agree to make payment of my admission.</p>
</ion-row>
<ion-row>
</ion-row>
<ion-button [disabled]= "!f.value.checking" color="secondary" type="submit" >
Make Payment
</ion-button>
</ion-card-content>
</ion-card>
</form>
`
Assign to the backing model property or FormControl
in the controller. You virtually never want anything to do with the checked
attribute.
remove ngModel attribute in your checkbox
<ion-checkbox slot="end" checked="false" name="checking"></ion-checkbox>
if this ngModel attribute is mandatory try this example
HTML
<ion-checkbox slot="end" checked="false" [(ngModel)]="checking" name="checking"></ion-checkbox>
ts
checking = false;
It works. But why there is a bug with ngModel?