I am showing a Component EventFeedbackComponent via ModalController. Now I want to subscribe to a Subject in EventFeedbackComponent. How do I get access to the component instance, to achieve my goal.
My current code:
let modal = this.modalCtrl.create(EventFeedbackComponent);
modal.present();
// This is not working. Throws the error "ERROR TypeError: Cannot read property 'subscribe' of undefined"
modal._component.feedbackSubmit.subscribe(feedbackResponse => {
console.log(feedbackResponse);
});
Documentation didn't help in this regard: https://ionicframework.com/docs/api/components/modal/ModalController/
My use case:
- I have a list of Events in my
Service, for which I need to get Feedback. EventFeedbackComponenthas controls to get Feedback for a Single Event.- Now, I show the EventFeedbackComponent to get feedback for First Event and listen for the event
feedbackSubmitviaSubject - On submission of
feedback, I show a Success Toast and switch my service variable in Service to show next event. - Above point is repeated, till I get feedback for all Unreviewed events with the same Component shown via Model.