IONIC BUG!? Ionic 4

when using ngModel in the ion-segment tag checked does not work anymore? Is this a bug?
This is my example

    <ion-segment [(ngModel)]="prefs">
      <ion-segment-button value="athan" checked>
      <ion-icon name="camera"></ion-icon>
        Athan
      </ion-segment-button>
      <ion-segment-button value="city">
      <ion-icon name="map"></ion-icon>
        City
      </ion-segment-button>
      <ion-segment-button value="language">
      <ion-icon name="globe"></ion-icon>
        Language
      </ion-segment-button>
      <ion-segment-button value="gps">
      <ion-icon name="locate"></ion-icon>
        GPS
      </ion-segment-button>
    </ion-segment>


  <div [ngSwitch]="prefs">
    <ion-list *ngSwitchCase="'athan'">
      <ion-item>
        <h2>Athan</h2>
      </ion-item>
    </ion-list>

    <ion-list *ngSwitchCase="'city'">
      <ion-item>
        <h2>City</h2>
      </ion-item>
    </ion-list>

    <ion-list *ngSwitchCase="'language'">
      <ion-item>
        <h2>Language</h2>
      </ion-item>
    </ion-list>

    <ion-list *ngSwitchCase="'gps'">
      <ion-item>
        <h2>GPS</h2>
      </ion-item>
    </ion-list>
  </div>

Try setting prefs initial value to 'athan' in your ts file. Then you shouldn’t need the checked attribute

1 Like