I have a socket.io client-server setup with AngularJS running on the client.
// Server.js
var io = require('socket.io')(server);
io.on('connection', function (socket) {
socket.on('message', function (msg) {
//console.log(msg);
console.log(msg);
io.emit('message', msg);
});
});
As observed, it essentially emits a message
events with the data stored in the variable msg
.
And then I have the following client code.
var container = angular.module("AdminApp", []);
container.controller("StatsController", function($scope) {
var socket = io.connect();
socket.on('message', function (msg) {
console.log(msg);
$scope.frontEnd = msg;
});
});
I now am facing a weird problem. When I write the following code snippet to print frontEnd
, it doesn't show up. But the console.log(msg);
works and it shows me the data emitted from the variable msg
.
<body ng-app="AdminApp">
<div ng-controller="StatsController">
<p>{{frontEnd}}</p> //Doesn't show anything
</div>
</body>
Can anyone help me out?