How to make switch inside ion-item-sliding work?

I’m trying to make switch inside ion-item-sliding work, here is the plunker:

It shows empty elements. How can I make it show real elements?

ngSwitch has given me nothing but grief. It will work if you refactor it to use multiple *ngIfs as follows:

  <ion-list>
    <ion-item-group reorder="true" (ionItemReorder)="reorderItems($event)">
      <ion-item-sliding *ngFor="let item of elements" >
        <ion-item *ngIf="item.type === 'other'">
            {{item.title}}
        </ion-item>

        <ion-item *ngIf="item.type === 'check'">
            <ion-label>{{item.title}}</ion-label>
            <ion-checkbox ></ion-checkbox>
        </ion-item>
      </ion-item-sliding>
    </ion-item-group>
  </ion-list>

1 Like

Thank you very much, it works now.

But should we add a issue to github, or is there one already?

I’m not certain where in the Angular/Ionic relationship the issue actually lies, actually. I’ve just found myself happier after deciding to pretend ngSwitch doesn’t exist. It’s not as if it adds anything in the way of functionality, and I don’t consider it noticeably more readable than this alternative.

1 Like