I have a component with a button that triggers showSummary()
when clicked that calls a service Appraisal-summary.service.ts
that has a method calc()
showSummary(appraisal) {
this.summaryService.calc(appraisal);
}
with service Appraisal-summary.service.ts
:
calc(appraisal) {
...
//a 'scores' array is created (synchronously)
return this.scores;
}
How do I listen for the synchronous result this.scores
to trigger a function in an unrelated component summary.component.ts
(that has already been initialised) that will use scores
.
something like:
summary.component.ts
:
ngOnInit(): void {
service.subscribe(scores => this.data = scores)
}