angular-socket-io io 未定义
angular-socket-io io is not defined
这里有一个建议:https://github.com/btford/angular-socket-io/issues/127
确保您有 socket.io 客户端库:
bower install socket.io-client --save
这并没有解决我的同样错误的问题。
包括 index.html:
script src="lib/angular-socket-io/socket.js"
在app.js
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services',
'starter.directives', 'btford.socket-io'])
在services.js
.factory('seatStatusSocket',function(socketFactory){
var myIoSocket = io.connect(porturl); // io is not defined here, suddenly.
它之前工作正常,使用的是 lib 的远程副本。当这个错误开始时,我将 index.html 更改为 link 一个本地副本,因为这个远程版本也收到了一个 Bad Gateway 错误(现在好了,但仍然没有像上面那样定义套接字 io)。
删除:
script src="http://chat.socket.io/socket.io/socket.io.js"
版本
socket.io@1.3.7 node_modules/socket.io
node --version
v0.12.7
您必须在 index.html 中包含:
script src="<bowerComponentPath>/socket.io-client/socket.io.js"
在此之前:
script src="<bowerComponentPath>/angular-socket-io/socket.js"
是的,这是必需的:
bower install socket.io-client --save
这里有一个建议:https://github.com/btford/angular-socket-io/issues/127
确保您有 socket.io 客户端库:
bower install socket.io-client --save
这并没有解决我的同样错误的问题。
包括 index.html:
script src="lib/angular-socket-io/socket.js"
在app.js
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'starter.directives', 'btford.socket-io'])
在services.js
.factory('seatStatusSocket',function(socketFactory){ var myIoSocket = io.connect(porturl); // io is not defined here, suddenly.
它之前工作正常,使用的是 lib 的远程副本。当这个错误开始时,我将 index.html 更改为 link 一个本地副本,因为这个远程版本也收到了一个 Bad Gateway 错误(现在好了,但仍然没有像上面那样定义套接字 io)。
删除:
script src="http://chat.socket.io/socket.io/socket.io.js"
版本
socket.io@1.3.7 node_modules/socket.io
node --version
v0.12.7
您必须在 index.html 中包含:
script src="<bowerComponentPath>/socket.io-client/socket.io.js"
在此之前:
script src="<bowerComponentPath>/angular-socket-io/socket.js"
是的,这是必需的:
bower install socket.io-client --save