1

I have a component which takes in an Input parameter:

export class MapComponent implements OnInit {
   @Input() options: MapOptions<any>;
}

I page which opens this modal using the ionic ModalController:

async pickLocationModal() {
  const modal = await this.modalController.create({
    component: MapComponent
  });
  return await modal.present();
}

Additionally I have mapOptions stored in the page, which I would like to pass.

I can I pass my mapOptions to the Modal so the component will take it as an input?

2
  • Your question isn't clear at all. What's modalController? Is it your modal implementation? Commented Nov 6, 2019 at 1:15
  • Oops sorry I was using ionic I was under the impression it was built into angular it slipped my mind Commented Nov 6, 2019 at 1:22

1 Answer 1

4

I'm assuming you're using Ionic since this is the same implementation of ionic's ModalController.

According to their docs, it's possible by passing to componentProps:

async pickLocationModal() {
  const modal = await this.modalController.create({
    component: MapComponent,
    componentProps: { // <----------
      options: ...
    }
  });
  return await modal.present();
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I didn't even realize it was ionics until you said so. I'll mark this answer as correct when the time limit elapses

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.