Skip to content

Adding step 4 as a dependency. #153

Open
@staminna

Description

@staminna

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions