我有一个页面,我通过以下方式调用:
let profileModal = Modal.create(PopupPage);
this.nav.present(profileModal);
如何从我的 PopupPage 组件关闭此模式页面:
import { ElementRef } from '@angular/core';
import { Page } from 'ionic-angular';
@Page({
template: `
<ion-pane padding="" scroll="false">
<h2>Login with...</h2>
<p>Please select one of our social logins. We'll never post anything your name
<button class="button button-default button-full button-danger" style="background-color: #3b5998;"><i class="fa fa-facebook" aria-hidden="true"></i> Facebook</button>
<button class="button button-default button-full button-danger" style="background-color: #db3236;"><i class="fa fa-google" aria-hidden="true"></i> Google</button>
</ion-pane>`,
host: {
"(document: click)": "globalClicked( $event )"
}
})
export class PopupPage {
constructor(private elmRef: ElementRef) {}
globalClicked( event ) {
if( !this.eventTriggeredInsideHost(event)) alert('NOW');
}
eventTriggeredInsideHost( event ) {
var current = event.target;
var host = this.elmRef.nativeElement.getElementsByTagName('ion-pane')[0];
do {
if ( current === host ) {
return (true);
}
current = current.parentNode;
} while ( current );
return (false);
}
}