janpantel / angular-sails

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

emit event #67

Closed iloverails closed 9 years ago

iloverails commented 9 years ago

Hi, can you answer please how can I use emit events?

TheSharpieOne commented 9 years ago

You can access the actual socket connection through $sails._raw. From there you can get to the emit method via $sails._raw.emit.

To use emit you must pass it an endpoint/url, request data, and a callback like this:

$sails._raw.emit('/api/endpoint', {
    something: 'anything
  }, function(response){
    console.log(response);
});