mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-15 17:42:15 +08:00
refactor(modal): use framework delegate for mounting the user's component
This commit is contained in:
@ -10,7 +10,8 @@ const routes: Routes = [
|
||||
{ path: 'actionSheet', loadChildren: 'app/action-sheet/action-sheet.module#ActionSheetModule' },
|
||||
{ path: 'toast', loadChildren: 'app/toast/toast.module#ToastModule' },
|
||||
{ path: 'loading', loadChildren: 'app/loading/loading.module#LoadingModule' },
|
||||
{ path: 'nav', loadChildren: 'app/nav/nav.module#NavModule' }
|
||||
{ path: 'nav', loadChildren: 'app/nav/nav.module#NavModule' },
|
||||
{ path: 'modal', loadChildren: 'app/modal/modal.module#ModalModule' }
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
@ -24,4 +24,7 @@
|
||||
<li>
|
||||
<a href='nav'>Nav Page</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='modal'>Modal Page</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -0,0 +1,35 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'page-one',
|
||||
template: `
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Page One</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
Page One
|
||||
<ul>
|
||||
<li>ngOnInit - {{ngOnInitDetection}}</li>
|
||||
</ul>
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
export class ModalPageToPresent {
|
||||
|
||||
ngOnInitDetection = 'initial';
|
||||
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
console.log('page one ngOnInit');
|
||||
setInterval(() => {
|
||||
this.ngOnInitDetection = '' + Date.now();
|
||||
}, 500);
|
||||
}
|
||||
|
||||
}
|
35
packages/demos/angular/src/app/modal/modal-page.component.ts
Normal file
35
packages/demos/angular/src/app/modal/modal-page.component.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { ModalController } from '@ionic/angular';
|
||||
import { ModalPageToPresent } from './modal-page-to-present';
|
||||
|
||||
@Component({
|
||||
selector: 'app-modal-page',
|
||||
template: `
|
||||
<ion-app>
|
||||
<ion-page class="show-page">
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Test</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content padding>
|
||||
<ion-button (click)="clickMe()">Open Basic Modal</ion-button>
|
||||
</ion-content>
|
||||
</ion-page>
|
||||
</ion-app>
|
||||
`
|
||||
})
|
||||
export class ModalPageComponent {
|
||||
|
||||
constructor(private modalController: ModalController) {
|
||||
}
|
||||
|
||||
clickMe() {
|
||||
const modal = this.modalController.create({
|
||||
component: ModalPageToPresent
|
||||
});
|
||||
return modal.present();
|
||||
}
|
||||
|
||||
}
|
14
packages/demos/angular/src/app/modal/modal-routing.module.ts
Normal file
14
packages/demos/angular/src/app/modal/modal-routing.module.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
|
||||
import { ModalPageComponent } from './modal-page.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', component: ModalPageComponent }
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class ModalRoutingModule { }
|
27
packages/demos/angular/src/app/modal/modal.module.ts
Normal file
27
packages/demos/angular/src/app/modal/modal.module.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { IonicAngularModule } from '@ionic/angular';
|
||||
|
||||
import { ModalPageComponent } from './modal-page.component';
|
||||
import { ModalRoutingModule } from './modal-routing.module';
|
||||
|
||||
import { ModalPageToPresent } from './modal-page-to-present';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
IonicAngularModule.forRoot(),
|
||||
ModalRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
ModalPageComponent,
|
||||
ModalPageToPresent
|
||||
],
|
||||
providers: [
|
||||
],
|
||||
entryComponents: [
|
||||
ModalPageToPresent
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
})
|
||||
export class ModalModule { }
|
Reference in New Issue
Block a user