Angular-socket-io io not defined

Here was a suggestion: https://github.com/btford/angular-socket-io/issues/127

  • make sure you have the socket.io client library:

    bower install socket.io-client --save 

This did not fix my problem with the same error.

  • including in index.html:

     script src="lib/angular-socket-io/socket.js" 
  • in app.js

     angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'starter.directives', 'btford.socket-io']) 
  • in services.js

     .factory('seatStatusSocket',function(socketFactory){ var myIoSocket = io.connect(porturl); // io is not defined here, suddenly. 
  • It worked before using a remote copy of lib. When this error started, I changed index.html to link the local copy, since this remote version also received a Bad Gateway error (now this is normal, but the io socket is still not defined as indicated above).

deleted:

 script src="http://chat.socket.io/socket.io/socket.io.js" 

version

 socket.io@1.3.7 node_modules/socket.io node --version v0.12.7 
+5
source share
1 answer

You should include in index.html:

 script src="<bowerComponentPath>/socket.io-client/socket.io.js" 

before:

 script src="<bowerComponentPath>/angular-socket-io/socket.js" 

and yest is required:

 bower install socket.io-client --save 
+10
source

Source: https://habr.com/ru/post/1234771/


All Articles