Here is the code snippet I am using to display a modal from the HomePage.
import { SignaturePage } from '../signature/signature'
import { NavController, NavParams, ModalController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html',
})
export class QuotationPage {
constructor(public navCtrl: NavController, public navParams: NavParams, public modalController:ModalController) {
this.signatureImage = navParams.get('signatureImage');
}
//Clicking on the approve button will trigger the modal to appear
approvebtn(){
let modal = this.modalController.create(SignaturePage,{
"text": "something"
});
modal.present();
}
}
TS code for the modal page. When attempting to set the home page as the root page, the navigation does not work and the setRoot function also fails for setting the root page.
import { Component, ViewChild } from '@angular/core';
import { NavController, NavParams, ViewController} from 'ionic-angular';
import {SignaturePad} from 'angular2-signaturepad/signature-pad';
import { HomePage } from '../home/home';
@Component({
selector: 'page-signature',
templateUrl: 'signature.html',
})
export class SignaturePage {
@ViewChild(SignaturePad) public signaturePad : SignaturePad;
@ViewChild('myNav') nav: NavController;
quotetext:any = "";
public signaturePadOptions : Object = {
'minWidth': 2,
'canvasWidth': 320,
'canvasHeight': 348
};
public signatureImage : string;
constructor(public navCtrl: NavController, public navParam:NavParams, public viewCtrl:ViewController) {
}
drawCancel() {
this.viewCtrl.dismiss();
}
Below is the transition function
drawComplete() {
this.signatureImage = this.signaturePad.toDataURL();
this.navCtrl.setRoot(HomePage);
}
drawClear() {
this.signaturePad.clear();
}
}