Last checkbox Unchecked in Ionic 4

In my scenario having checkbox if all checkbox are checked, then ‘any checkbox’ checked by default, that time all the checkbox are unchecked except ‘any checkbox’ but last checkbox was not unchecked. I used the $event for checking or uncheck.

Le me give a example code

<ion-item>
                <ion-label >A/C</ion-label>
               
                <ion-checkbox  (ionChange)="choose_type('type','A/C',$event)" ></ion-checkbox>
            </ion-item>

The ts file will be look like this.

choose_type(type: string, value: any, event: any) {
    let index;
    
    if (event.checked === true)
     {
       console.log('Pushed into array');
        this.user_filter[type].push(value);
       }
 else
      {
       
        index = this.user_filter[type].indexOf(value);
        this.user_filter[type].splice(index, 1);
    }
   
}

In my case i have an array called user_filter .it will push values if the event.checked is true , else it will splice the index from the array .Hope this one will help you