mirror of
https://github.com/arnaucube/socketioMEANseed.git
synced 2026-02-07 11:46:48 +01:00
init
This commit is contained in:
9
www/chat/chat.html
Normal file
9
www/chat/chat.html
Normal file
@@ -0,0 +1,9 @@
|
||||
a
|
||||
<ul id="messages">
|
||||
<li ng-repeat="msg in msgs track by $index">
|
||||
{{msg}}
|
||||
</li>
|
||||
</ul>
|
||||
<form>
|
||||
<input id="m" ng-model="msg.text" /><button ng-click="send()">Send</button>
|
||||
</form>
|
||||
22
www/chat/chat.js
Normal file
22
www/chat/chat.js
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('myApp.chat', [
|
||||
'btford.socket-io', 'ngRoute'
|
||||
])
|
||||
.controller('ChatCtrl', function ($scope, socket) {
|
||||
$scope.msgs=[];
|
||||
|
||||
socket.on('newmsg', function (data) {
|
||||
console.log(data);
|
||||
$scope.msgs.push(data.text);
|
||||
});
|
||||
$scope.msg={
|
||||
text: ""
|
||||
};
|
||||
$scope.send = function(){
|
||||
console.log("emitting");
|
||||
socket.emit("msg", $scope.msg, function(data){
|
||||
|
||||
});
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user