angular-websocket
WebSockets for Angular.js
Email me if something is broken.
#How do I add this to my project?
You can download angular-websocket by:
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular.min.js"></script>
<script src="app/bower_components/angular-websocket/angular-websocket.js"></script>
<script>
angular.module('YOUR_APP', [
'angular-websocket',
'controllers'
])
.config(function(WebSocketProvider){
WebSocketProvider
.prefix('')
.uri('ws://echo.websocket.org/');
});
angular.module('controllers', [])
.controller('MainCtrl', function($scope, WebSocket) {
WebSocket.onopen(function() {
console.log('connection');
WebSocket.send('message')
});
WebSocket.onmessage(function(event) {
console.log('message: ', event.data);
});
});
</script>