I have a sliding item that when you swipe it open, it reveals a submit button.
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...
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.
Basic UsageSliding 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.
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 variableslidingItem
is placed on the element and passed to theshare
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(); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With