I am opening a modal using component as a template, everything is ok, modal opens and I am subscribing to onHide Event, subscription works also.
but I have a challenge here, I want to send a specific reason for example: 'message added successfully' as the reason . how can I do that? how can I send a specific string as a reason?
currently, I am trying to set a value in MessageAddComponent component and access it in parent component using bsModalRef.Content, but it is not a good idea.
newMessage() {
this.bsModalRef = this.modalService.show(MessageAddComponent, {
class: 'modal-lg'
});
this.subscriptions.push(this.modalService.onHide.subscribe((reason: string) => {
// i dont like this approach
if (this.bsModalRef.content.anySuccessfulAction) {
console.log('foo and bar')
}
this.unsubscribe();
}));
}
found solution finally:
inject BsModalService in the component that is used as modal and then set dismiss reason as bellow
this.modalService.setDismissReason(theReason);