您只需将您的模态页面模块名称添加app-module.ts
到import:[ your -modal-module-page-name]
. 如果您想将模式调用到页面中,则无需调用页面模块
import { Component, OnInit } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { CountryCodePage } from '../country-code/country-code.page';
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit {
constructor(public modalController: ModalController) { }
ngOnInit() {
}
openCountryModal(){
this.presentModal();
}
async presentModal() {
const modal = await this.modalController.create({
component: CountryCodePage,
componentProps:{"dataArr":{
FirstName:"chitranjan",
Lastname:"soni",
Ambition :"coding"
}}
});
return await modal.present();
}
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
import { Component, OnInit ,Input } from '@angular/core';
import { NavParams } from '@ionic/angular';
@Component({
selector: 'app-country-code',
templateUrl: './country-code.page.html',
styleUrls: ['./country-code.page.scss'],
})
export class CountryCodePage implements OnInit {
@Input() dataArr: string;
constructor(private navParams: NavParams) {
console.log(JSON.stringify(navParams.get('dataArr')));
}
ngOnInit() {
}
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { HttpClientModule } from '@angular/common/http';
import { CountryCodePageModule } from './country-code/country-code.module';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule,CountryCodePageModule,
HttpClientModule],
providers: [
StatusBar,
SplashScreen,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule {}