Using socket.io with nodejs and angular
myApp.factory('socket', function ($rootScope) {
var socket = io.connect('http://localhost');
'io' not defined error
In express i'm writing:-
var io = require('socket.io').listen(app.listen(app.get('port')));
io.sockets.on('connection', function (socket) {
console.log('io.socket connection');
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
The server is not showing error.
I am trying to follow this tutorial.
Edit:-
when i add <script src="http://cdn.socket.io/stable/socket.io.js"></script>
it says connect
is not a method of object 'io'