mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
docs(demos): modal demo outline
This commit is contained in:
46
demos/component-docs/modal.ts
Normal file
46
demos/component-docs/modal.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import {App, IonicApp, Modal, NavController, IonicView, Events} from 'ionic/ionic';
|
||||
import * as helpers from 'helpers';
|
||||
|
||||
@IonicView({
|
||||
templateUrl: 'modal.html'
|
||||
})
|
||||
class ModalFirstPage {
|
||||
|
||||
constructor(
|
||||
nav: NavController,
|
||||
modal: Modal,
|
||||
events: Events
|
||||
) {
|
||||
this.nav = nav;
|
||||
this.modal = modal;
|
||||
window.onmessage = (e) => {
|
||||
zone.run(() => {
|
||||
if (e.data) {
|
||||
var data = JSON.parse(e.data);
|
||||
var componentTitle = helpers.toTitleCase(data.hash.replace('-', ' '));
|
||||
events.publish('page:locationChange', { componentName: componentTitle });
|
||||
this.closeModal();
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
closeModal() {
|
||||
let modal = this.modal.get();
|
||||
if (modal) {
|
||||
modal.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@IonicView({
|
||||
template: '<ion-nav [root]="rootView"></ion-nav>'
|
||||
})
|
||||
export class DemoModal {
|
||||
constructor() {
|
||||
this.rootView = ModalFirstPage;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user