I attempted to update my view upon receiving a socket event. This is what my component code looks like:
constructor(private _zone: NgZone){
this.socket = io.connect('http://localhost:3000');
this.socket.on('someEvent', function(data) {
this._zone.run(() => {
this.dataItem = data.item;
console.log(this.dataItem);
});
});
}
After running the code, I encountered errors in the browser console:
EXCEPTION: TypeError: Cannot read property 'run' of undefined
By the way, the socket events are functioning properly in index.html.
Any assistance would be greatly appreciated.