How to closeSlidingItems()?

I see this in the API docs for the list component:

import { Component, ViewChild } from '@angular/core';
import { List } from 'ionic-angular';

@Component({...})
export class MyClass {
  @ViewChild(List) list: List;

  constructor() { }

  stopSliding() {
    this.list.enableSlidingItems(false);
  }
}

but this.list.closeSlidingItems() does nothing. Do I need to do something in my template to bind the list to this.list? I tried putting [(ngModel)]=“list” in the ion-list but it won’t take it.

[Ionic 2 RC1]

I had a simliar issue. The debugger said “closeSlidingItems ist not a method” for my list. It seems to b defined in typings but is not implemented during runtime.

My workaround to close all slidingItems for dynamic generated items was:

  1. Give them an id, i.e. <ion-item-sliding #slidingItems *ngFor=“let profile of profileList; let id = index;”>…

  2. Use @ViewChildren(‘slidingItems’) public slidingItems: QueryList; in your component.

  3. Close them manually (I did this during “ionViewWillEnter”)
    this.slidingItems.forEach((item) => {
    item.close();
    });

2 Likes

Thanks, Luckow. That’s a good solution!