Open
Description
I tried to kickstart the express-> angular code with https://www.npmjs.com/package/angular-socket-io
but the step
4: Add btford.socket-io as a module dependency to your app. ( I didn't understood)
When I require=('socket.io') in node, there is a error on the console, dispite I have the socket.io.js file included on my HTML
socket.io.js:12 Uncaught ReferenceError: require is not defined
at socket.io.js:12
Here is my controller code:
// 'use strict';
// in the top-level module of the app
angular.module('Outlook', [
'btford.socket-io',
'Outlook.MyCtrl'
]).
factory('mySocket', function (socketFactory) {
return socketFactory();
}).
controller('Outlook', function (mySocket) {
// ...
}).factory('socket', function ($rootScope) {
var socket = io.connect();
return {
on: function (eventName, callback) {
socket.on(eventName, function () {
var args = arguments;
$rootScope.$apply(function () {
callback.apply(socket, args);
});
});
},
};
});
I have used socket.io without any libraries before, but not in a MEAN stack way. I am certain I am missing something, but I'm not quite sure. Can you help with a hello world example? Thank you,
Jorge
Metadata
Metadata
Assignees
Labels
No labels