0

I am in LotoReviewTabComponent and another component is imported here - import { ReviewComponent } from './loto.reviewdoc.component';

My requirement is to call a method of LotoReviewTabComponent inside ReviewComponent.

Reason ReviewComponent is imported in LotoReviewTabComponent is - there is a modalreference call in LotoReviewTabComponent as below -

Const reviewModal = this.modalService.open(ReviewComponent, ngbModalOptions);
reviewModal.componentInstance.fileName = fileName;

when some event is performed in that modal - reviewModal, a method in LotoReviewTabComponent has to be called.

how can this be achieved?.

Manojkumar
  • 1,351
  • 5
  • 35
  • 63

1 Answers1

0

You can use an Output event from angular in the ReviewComponent.

With this you can let the parent component (LotoReviewTabComponent) know that it has to do something. In this case, run a method.

R. de Ruijter
  • 513
  • 5
  • 13
  • 1
    the component is imported. it's not a parent – rhavelka Dec 01 '20 at 14:45
  • @Manojkumar The same idea still stands you just have to catch the event a little different you now have to do something like this `reviewModal.instance.nameOfOutputEvent.subscribe((event) => {yourMethod()})` – R. de Ruijter Dec 01 '20 at 14:49
  • yes, I am importing the component hence it is not child. Else there is a ready example - https://stackoverflow.com/questions/43323272/angular-4-call-parent-method-in-a-child-component – Manojkumar Dec 02 '20 at 05:55