Javascript 实时表AngularJS
我正在使用Twitter流API。我的服务器从concretes标签获取推文。为此,我使用IO插槽。客户端从套接字接收消息:Javascript 实时表AngularJS,javascript,angularjs,sockets,web,Javascript,Angularjs,Sockets,Web,我正在使用Twitter流API。我的服务器从concretes标签获取推文。为此,我使用IO插槽。客户端从套接字接收消息: socket.on('tweet',函数(msg){ 控制台日志(msg); $scope.streaming.push(msg); });socket。在上,回调将耗尽一个周期,因此您不会看到结果 因此,您需要通过调用$apply或$timeout来触发摘要周期 例如: socket.on('tweet', function(msg){ console.log
socket.on('tweet',函数(msg){
控制台日志(msg);
$scope.streaming.push(msg);
});代码>socket。在
上,回调将耗尽一个周期,因此您不会看到结果
因此,您需要通过调用$apply
或$timeout
来触发摘要周期
例如:
socket.on('tweet', function(msg){
console.log(msg);
$timeout(function(){
$scope.streaming.push(msg);
});
});
我不知道你们的代码,但看起来通过停止服务器你们也触发了一个摘要周期,导致你们的东西呈现出来