I have a function within a service that subscribes to an event, rather than the component. The data from this event is stored in message.content
.
Take a look at the code:
Service Function:
myMethod() {
this.socket$.subscribe(
(message) => {
console.log(`${message.content}`);
}
);
}
App Component
contentVariable;
ngOnInit() {
this.myservice.myMethod();
}
My query is...how can I transfer the value of message.content from the service into contentVariable within my component?