Ion-select with "select all" option

Thank you for your time.

Now I create the button

<ion-item>
  <ion-label>Categories</ion-label>
  <ion-select [(ngModel)]="categories" multiple="true">
    <ion-option (ionSelect)="allClickedCategories()">Select/Deselect All</ion-option>
    <ion-option *ngFor="let item of categoriesitems" value="{{item.name}}">{{item.name}}</ion-option>
  </ion-select>
</ion-item>

and this is my function in ts

  allClickedCategories() {
    this.categories = [];
    for (var i = 0; i < this.categoriesitems.length; i++) {
      this.categories.push(this.categoriesitems[i].name)
    }
  }

but when i click on this button the flag near the option don’t show but this options are in array and when i click again on the select i show the flag.

There is an option to refresh the select or a method that does this?

FIRST CLICK:

SECOND CLICK:

Thank You!