One of my components contains a button that activates the showSummary()
function when clicked, which then calls a service named Appraisal-summary.service.ts
that includes a method called calc()
.
showSummary(appraisal) {
this.summaryService.calc(appraisal);
}
The Appraisal-summary.service.ts
service looks like this:
calc(appraisal) {
...
//an array called 'scores' is created (synchronously)
return this.scores;
}
I am trying to figure out how to detect the synchronous result this.scores
and use it to trigger a function in a completely separate component named summary.component.ts
(which has already been initialized) that will utilize scores
.
For example, something like this in summary.component.ts
:
ngOnInit(): void {
service.subscribe(scores => this.data = scores)
}