I try to update and display message from variable updated into EventSource function:
ngOnInit(): void {
const EventSource: any = window['EventSource'];
const fx = new EventSource('/weather/update/');
fx.onmessage = function (evt) {
this.newMessage = evt.data;
console.log(this.newMessage);
}
}
in template:
<p>{{newMessage}}</p>
The received message always is empty, but in console i can see the new message.