chrisenytc / ng-socket

Angular Module for Socket.io
MIT License
49 stars 18 forks source link

connect method #4

Closed sajankumar closed 9 years ago

sajankumar commented 10 years ago

Can you tell me how to fix this ?

TypeError: Cannot call method 'connect' of undefined at Object. (http://localhost:8888/SPA_Application/server/js/ngSocket.js:17:23) at Object.d as invoke at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:35:77 at c (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:33:83) at Object.d as invoke at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:35:77 at c (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:33:83) at d (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:33:300) at Object.instantiate (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:33:464) at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:65:486

chrisenytc commented 10 years ago

You must declare a 'socket.io.js' statements before all scripts of your system.

<script src="/path/to/socket.io.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
loadedsith commented 9 years ago

With requirejs:

//require.config.js
shim:{
    'ng-socket': {
      deps: [
        'angular'
        './startSocketIo',
      ]
  }

//startSocketIo.js
define([
  'socket.io-client'],function(io) {
    'use strict';
    window.io = io;
  });