mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
overlay getByHandle
This commit is contained in:
@@ -43,7 +43,8 @@ class IonicApp {
|
||||
openModal() {
|
||||
Modal.open(ContactModal, {
|
||||
enterAnimation: 'my-fade-in',
|
||||
leaveAnimation: 'my-fade-out'
|
||||
leaveAnimation: 'my-fade-out',
|
||||
handle: 'my-awesome-modal'
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -72,6 +73,9 @@ export class ContactModal extends Modal {
|
||||
<p>
|
||||
<button primary (click)="openActionMenu()">Open Action Menu</button>
|
||||
</p>
|
||||
<p>
|
||||
<button primary (click)="closeByHandeModal()">Close By Handle</button>
|
||||
</p>
|
||||
<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>
|
||||
<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>
|
||||
</ion-content>
|
||||
@@ -94,6 +98,11 @@ export class ModalFirstPage {
|
||||
modal.close();
|
||||
}
|
||||
|
||||
closeByHandeModal() {
|
||||
let modal = Modal.getByHandle('my-awesome-modal');
|
||||
modal.close();
|
||||
}
|
||||
|
||||
openActionMenu() {
|
||||
ActionMenu.open({
|
||||
buttons: [
|
||||
|
||||
@@ -63,6 +63,7 @@ export class Overlay {
|
||||
IonicRoot.append(ComponentType).then(ref => {
|
||||
let overlay = ref.instance;
|
||||
overlay._type = overlayType;
|
||||
overlay._handle = opts && opts.handle;
|
||||
overlay._dispose = ref.dispose;
|
||||
overlay._domElement = ref.elementRef.domElement;
|
||||
overlay.extendOptions(opts);
|
||||
@@ -78,7 +79,16 @@ export class Overlay {
|
||||
|
||||
static getByType(overlayType) {
|
||||
for (let i = overlayStack.length - 1; i >= 0; i--) {
|
||||
if (overlayType == overlayStack[i]._type) {
|
||||
if (overlayType === overlayStack[i]._type) {
|
||||
return overlayStack[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static getByHandle(handle) {
|
||||
for (let i = overlayStack.length - 1; i >= 0; i--) {
|
||||
if (handle === overlayStack[i]._handle) {
|
||||
return overlayStack[i];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user