Show Hide In Ionic Framework
I want a show hide function for my ionic app: Below is what I have done so far, in xyz.html file:
Solution 1:
Use the Renderer2 to addClass, setStyle, or whatever you want, passing the element reference to your click event handler
Here a Demo
HTML
<ion-item *ngFor="let item of items">
<h3 #text>{{item}}</h3>
<button ion-button item-right (click)="onShow(text)">Show</button>
<button ion-button color="danger" item-right (click)="onHide(text)">Hide</button>
</ion-item>
TS
import { Component, Renderer2 } from '@angular/core';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
public items: string[] = [
"Item 1",
"Item 2",
"Item 3",
"Item 4",
"Item 5",
"Item 6",
"Item 7",
"Item 8",
"Item 9",
"Item 10",
];
public PtagClicked: boolean = false;
constructor(public navCtrl: NavController, private render: Renderer2) { }
public onShow(controlToShow) {
this.render.setStyle(controlToShow, 'visibility', 'visible');
}
public onHide(controlToHide) {
this.render.setStyle(controlToHide, 'visibility', 'hidden');
}
}
Post a Comment for "Show Hide In Ionic Framework"