btford / btford/angular-socket-io

Adding step 4 as a dependency.

Open
#153 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.5k
Forks
225
PR merge metrics
No merged PRs in 30d

Description

I tried to kickstart the express-> angular code with [https://www.npmjs.com/package/angular-socket-io](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)

> https://www.npmjs.com/package/angular-socket-io

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.