0
我只是試圖更新我的視圖,當我收到一個套接字事件。 我在組件的代碼是一樣的東西如下:Angular2:View沒有從Socket.io事件更新
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);
});
});
}
當我運行該瀏覽器控制檯顯示一些錯誤:
EXCEPTION: TypeError: Cannot read property 'run' of undefined
順便說一句,我的插座事件中正確的index.html工作
任何形式的幫助表示讚賞。