ionic modalcontroller pass data code example

Example 1: ionic modal pass data

...
async presentModal() {
    const modal = await this.modalController.create({
      component: ModalPage,
      componentProps: { 
        foo: 'hello',
        bar: 'world'
      }
    });
    return await modal.present();
}
...
@Component()
export class ModalPage implements OnInit {
  foo;
  bar;

  ngOnInit() {
    console.log(`${foo} ${bar}`)
  }
}

Example 2: ionic modal controller pass parameter

let profileModal = await this.modalCtrl.create({
	component: SearchModal,
	componentProps: {
		specs: [this.specialization_selected]
	}
});