arnaucube
arnaucube/socketioMEANseedPublic Self-hosted repository
socketioMEANseed/www/index.js
www/index.jsRaw
 1'use strict';
 2
 3angular.module('myApp.chat', [
 4  'btford.socket-io', 'ngRoute'
 5])
 6.controller('ChatCtrl', function ($scope, socket) {
 7    $scope.msgs=[];
 8
 9  socket.on('newmsg', function (data) {
10      console.log(data);
11    $scope.msgs.push(data.text);
12  });
13  $scope.msg={
14      text: ""
15  };
16  $scope.send = function(){
17      console.log("emitting");
18      socket.emit("msg", $scope.msg, function(data){
19
20      });
21  };
22});