janpantel / angular-sails

An angular module for using the sails socket.io api
MIT License
307 stars 56 forks source link

angular.js:10126 TypeError: Cannot read property 'once' of undefined #53

Closed misterch0c closed 9 years ago

misterch0c commented 9 years ago

I just made a new project using slush. Then bower install angular-sails --save Used your example code and error. See the gist for code and error https://gist.github.com/misterch0c/b30aec433062cdb0c44b

TheSharpieOne commented 9 years ago

What version of sails.io.js are you using?

But what is happening is sails.io.js doesn't have a .once() method so angular-sails tries to grab it from the "raw" socket that is exposed through sail.io.js, but it appears that the "raw" socket is not there.

misterch0c commented 9 years ago

// socket.io-1.2.1 // (from http://socket.io/download/) Got it from the bower install and it seems to have the .once() method

TheSharpieOne commented 9 years ago

sails.io.js is a dependency of angular-sails and must be included. We removed this dependency in the next version which should be released within the next month or so.

While socket-io is in sails.io.js, it is only exposed when a connection is made. It is exposed through the _raw property. It would appear that the socket was not connected and thus angular-sails was not able to get at the .once() method when it tried.

misterch0c commented 9 years ago

Sorry that header was from the header of another sails.io.js .. "name": "sails.io.js", "main": "dist/sails.io.js", "version": "0.11.4" So I ran bower update sails.io.js to get 0.11.5 but I'm still facing the same error

TheSharpieOne commented 9 years ago

Because .once() is different from on and off (its not exposed directly), it is a special case and we should expose it differently.

TheSharpieOne commented 9 years ago

Ok, there is a new build that has been released that should solve your issue.. The new release is 1.1.1 and you should be able to get it via bower.

misterch0c commented 9 years ago

Works like a charm now, thank you