<!doctype>
<html ng-app="app">
<head>
<meta charset="utf8"/>
<title>Example</title>
<script src="angular1.4.5min.js"></script>
<script>
if(!window.WebSocket){
}
var ws = new window.WebSocket('ws://localhost:3000');
var globalObject = new Object();
ws.onopen = function(){
var command = new Object();
command.operation = 'getCountClients';
ws.send(JSON.stringify(command));
}
ws.onmessage = function(event) {
var data = JSON.parse(event.data);
if(data.operation == 'getCountClients'){
globalObject.countClients = data.count;
}
};
ws.onclose = function(event) {
};
var app = angular.module('app', []);
function MainCtrl(){
this.obj = globalObject;
}
app.controller('MainCtrl', MainCtrl);
</script>
</head>
<body ng-controller="MainCtrl as main">
<div>Сейчас на сайте <span ng-bind="main.obj.countClients"></span></div>
</body>
</html>
Не происходит обновление this.obj, что делать?