Ionic 2 - modal onPageWillEnter/onPageDidEnter weird behaviour


#1

If I display a modal page in onPageWillEnter or onPageDidEnter, odd behaviour seems to occur where the modal is built twice.

If I attempt to dismiss my modal when I initialise it in onPageWillEnter, I cannot and I seem to have infinite modals.

If I attempt to dismiss my modal when I initialise it in onPageDidEnter, I seem to have two modals build and once I have dismissed two, it seems fine.

If I present my modal using a click handler, just one modal is created and expected behaviour resumes.

Am I doing anything wrong. A basic example can be demonstrated here:

import {Modal, NavController, Page, ViewController} from 'ionic-angular';

@Page({
    template: `
        <ion-toolbar>
            <ion-title>
                Modal
            </ion-title>
            <ion-buttons start>
                <button (click)="dismiss()">
                    <span primary showWhen="ios">Close</span>
                    <ion-icon name="md-close" showWhen="android,windows"></ion-icon>
                </button>
            </ion-buttons>
        </ion-toolbar>
        <ion-content padding>
            <h1>My Modal Page</h1>
        </ion-content>
    `
})
class ModalPage {
	constructor(public viewCtrl: ViewController) {}

    dismiss() {
        this.viewCtrl.dismiss();
    }
}

@Page({
    template: `
    	<ion-navbar *navbar>
            <ion-title>
                Base
            </ion-title>
            <ion-buttons end>
                <button (click)="open()">
                    <span>Open</span>
                </button>
            </ion-buttons>
        </ion-navbar>
        <ion-content padding>
            <h1>My Base Page</h1>
        </ion-content>
    `
})
export class MainPage {
    constructor(public navCtrl: NavController) {}

    onPageWillEnter() {
        //this.showModal();
    }

    onPageDidEnter() {
        this.showModal();
    }

    open() {
    	this.showModal();
    }

    showModal() {
        let modal = Modal.create(ModalPage);
        this.navCtrl.present(modal);
    }
}

#2

Same issue here, onPageWillEnter and onPageDidEnter always trigger twice when setRoot to that page, very strange …