title: angularjs socket.io emit function
body: <p>Hi I'm building a web app that updates the user via socket.io how many tasks users have created on the website.  I'm using socket.emit on the node.js side that will send a message to the angularjs client everytime a client creates a new task.  However the codes doesn't execute, specifically the code inside this block in the node.js file:</p>
  
  <pre><code>  console.log('a');
   io.sockets.on('connection', function(socket) {
   console.log('b');
      io.sockets.emit('send', statinfo);
  });
    console.log('c');
  </code></pre>
  
  <p>When I look at the console I see "a" and "c" but not "b", as "b" is in that block of code that doesn't execute.</p>
  
  <p>Here the rest of my code:</p>
  
  <p>nodeapp.js (retrieves the numbers of tasks on the website)</p>
  
  <pre><code>    app.post('/api/addtasks',function(req, res){
  
  
  
      /*code to add tasks above*/
  
              Stat.update(
                      {_id: statid},
          {$inc: {'quantity': 1}},
          function(err) {
                    console.log('test');
  
               Stat.find({}, function(err, docs2) {
                  var statinfo = docs2;
       io.sockets.on('connection', function(socket) {
          io.sockets.emit('send', statinfo);
      });
              });
  
          });
  
  
      });
  </code></pre>