Hi,
I’m using ionic 3 and want to enlarge font size of text on a button click. But button is inside popover.
But it is not working.
Here is my code.
Popover.html
<ion-list>
<button (click)="changeFontSize(-0.2)" ion-button icon-only>
<ion-icon name="remove"></ion-icon>
</button>
<button (click)="changeFontSize(0.2)" ion-button icon-only>
<ion-icon name="add"></ion-icon>
</button>
</ion-list>
Popover.ts
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { ViewController } from 'ionic-angular';
@IonicPage()
@Component({
selector: 'page-popover',
templateUrl: 'popover.html',
})
export class PopoverPage {
constructor(public navCtrl: NavController, public navParams: NavParams, public viewCtrl: ViewController) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad PopoverPage');
}
//Change Font Size
textEle: any;
ngOnInit() {
if (this.navParams.data) {
this.textEle = this.navParams.data.textEle;
}
}
changeFontSize(direction: string) {
this.textEle.style.fontSize = direction;
}
}
ContentPage.html
<div #popoverText class="test">
<div class="inner-text">Demo Text Here</div>
</div>
ContentPage.ts
import { Component, ElementRef, ViewChild } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { PopoverController} from 'ionic-angular';
import { PopoverPage } from '../popover/popover';
@IonicPage()
@Component({
selector: 'page-content',
templateUrl: 'content-page.html',
})
export class ContentPage {
@ViewChild('popoverText', {read: ElementRef}) text: ElementRef;
constructor(
public navCtrl: NavController,
public navParams: NavParams,
public popoverCtrl: PopoverController
) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad ContentPage');
}
//Open Popover
presentPopover(ev: UIEvent) {
let popover = this.popoverCtrl.create(PopoverPage, {
textEle: this.text.nativeElement
});
popover.present({
ev: ev
});
//On Popover Close
popover.onDidDismiss(data => {
console.log("Test");
});
}
}