I am currently displaying a Component called EventFeedbackComponent
through ModalController. I want to subscribe to a Subject
within the EventFeedbackComponent
. How can I access the component instance in order to achieve this?
This is what my code looks like:
let modal = this.modalCtrl.create(EventFeedbackComponent);
modal.present();
// This code snippet is not functioning correctly and throws an error "ERROR TypeError: Cannot read property 'subscribe' of undefined"
modal._component.feedbackSubmit.subscribe(feedbackResponse => {
console.log(feedbackResponse);
});
The documentation provided did not offer assistance in solving this issue: https://ionicframework.com/docs/api/components/modal/ModalController/
Here is the scenario where I need to implement this:
- I have a list of Events in my
Service
that require feedback. - The
EventFeedbackComponent
contains features for gathering feedback on individual events. - I display the EventFeedbackComponent to collect feedback for the first event and listen for the event
feedbackSubmit
using aSubject
. - Upon submission of the
feedback
, I display a Success Toast message and update my service variable to move on to the next event. - This process is repeated until feedback is obtained for all unreviewed events, utilizing the same Component displayed through a Modal.