mirror of
https://github.com/arnaucube/socketioMEANseed.git
synced 2026-02-07 03:36:47 +01:00
init
This commit is contained in:
18
www/views/chat/chat.html
Normal file
18
www/views/chat/chat.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<md-content class="md-padding">
|
||||
<md-toolbar layout="row" class="o_purple300">
|
||||
<div class="md-toolbar-tools">
|
||||
<span>chat</span>
|
||||
</div>
|
||||
</md-toolbar>
|
||||
<form>
|
||||
<input id="m" ng-model="msg.text" /><button ng-click="send()">Send</button>
|
||||
</form>
|
||||
|
||||
<md-list flex>
|
||||
<md-subheader class="md-no-sticky">3 line item (with hover)</md-subheader>
|
||||
|
||||
<md-list-item ng-repeat="msg in msgs" ng-click="null">
|
||||
<p>{{msg.text}}</p>
|
||||
</md-list-item>
|
||||
</md-list>
|
||||
</md-content>
|
||||
22
www/views/chat/chat.js
Normal file
22
www/views/chat/chat.js
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.chat', [
|
||||
'btford.socket-io', 'ngRoute'
|
||||
])
|
||||
.controller('ChatCtrl', function ($scope, socket) {
|
||||
$scope.msgs=[];
|
||||
|
||||
socket.on('newmsg', function (data) {
|
||||
console.log(data);
|
||||
$scope.msgs.push(data);
|
||||
});
|
||||
$scope.msg={
|
||||
text: ""
|
||||
};
|
||||
$scope.send = function(){
|
||||
console.log("emitting");
|
||||
socket.emit("msg", $scope.msg, function(data){
|
||||
|
||||
});
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user