with Sharing connection between Browser's windows and tabs across local storage
-
download the files
- Bower
- add
"fs-socket-io": "latest"
to yourbower.json
file then runbower install
OR runbower install fs-socket-io
- add
- include the files in your app
fs-socket-io.js
- Bower
-
include the module in angular (i.e. in
app.js
) -fs-socket-io
angular.module("testApp", ['fs-socket-io']);
-
config path and prefix
angular.config("testApp", ['fsSocketIoProvider', function(fsSocketIoProvider){ fsSocketIoProvider.prefixShare('somePrefix'); fsSocketIoProvider.socketUrl('some/path/socket/connect'); }]);
-
init connect
angular.run("testApp", ['fsSocketIo', function(fsSocketIo){ }]);
-
In your controller
$scope.$on('socket:YourSocketEvent') fsSocketIo.emit('YourSocketEmitEvent', param)