Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding step 4 as a dependency. #153

Open
staminna opened this issue Feb 9, 2017 · 0 comments
Open

Adding step 4 as a dependency. #153

staminna opened this issue Feb 9, 2017 · 0 comments

Comments

@staminna
Copy link

staminna commented Feb 9, 2017

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)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant