Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ionic 3 Close ion-item-sliding

I have a sliding item that when you swipe it open, it reveals a submit button.

enter image description here

enter image description here

After you hit submit, I would like for the button to close and hide the "submit". I can't seem to find any documentation for closing sliding elements that relate to buttons or any hacks around it. Any suggestions? Working in Ionic 3...

like image 354
cdh429 Avatar asked Dec 28 '17 17:12

cdh429


People also ask

How do you close ion item sliding?

The sliding item can be closed by grabbing a reference to ItemSliding . In the below example, the template reference variable slidingItem is placed on the element and passed to the share method. Save this answer.

How do you use ion item sliding?

Basic Usage​Sliding item options are placed on the "end" side of the item by default. This means that options are revealed when the item is swiped from end to start, i.e. from right to left in LTR, but from left to right in RTL.


1 Answers

Just like you can see in the docs:

Close the sliding item. Items can also be closed from the List.

The sliding item can be closed by grabbing a reference to ItemSliding. In the below example, the template reference variable slidingItem is placed on the element and passed to the share method.

<ion-list>
  <ion-item-sliding #slidingItem>
    <ion-item>
      Item
    </ion-item>
    <ion-item-options>
      <button ion-button (click)="share(slidingItem)">Share</button>
    </ion-item-options>
  </ion-item-sliding>
</ion-list>

And then:

import { Component } from '@angular/core';
import { ItemSliding } from 'ionic-angular';

@Component({...})
export class MyClass {
  constructor() { }

  share(slidingItem: ItemSliding) {
    slidingItem.close();
  }
}
like image 78
sebaferreras Avatar answered Oct 13 '22 21:10

sebaferreras