title: How to include socket.io with angularjs and Express.js?
body: <p>Using socket.io with nodejs and angular</p>
  
  <pre><code>myApp.factory('socket', function ($rootScope) {
    var socket = io.connect('http://localhost');
  </code></pre>
  
  <p>'io' not defined error</p>
  
  <p>In express i'm writing:-</p>
  
  <pre><code>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);
    });
  });
  </code></pre>
  
  <p>The server is not showing error. </p>
  
  <p>I am trying to follow <a href="http://net.tutsplus.com/tutorials/javascript-ajax/real-time-chat-with-nodejs-socket-io-and-expressjs/" rel="nofollow">this</a> tutorial.</p>
  
  <p>Edit:- 
  when i add <code>&lt;script src="http://cdn.socket.io/stable/socket.io.js"&gt;&lt;/script&gt;</code></p>
  
  <p>it says <code>connect</code> is not a method of object 'io'</p>