Best way to provide a socket URL as a parameter to the socketFactory
Opened this issue · 1 comments
jlethuau commented
Hi!
Not really an issue but a question :)
Since I had the same 404 issues in my console with the example code, I've tried the solution provided here and it works great : #82
...
.factory('mySocket', function (socketFactory) {
return socketFactory({
ioSocket: io('http://XX.XX.XX.XX:12345') // Local ENV
// ioSocket: io('http://YY.YY.YY.YY:9000') // Staging
});
});
My problem: I need to switch between URLs when I deploy my app and it's painful if I have to do it manually in the app.js file everytime...
Question: How can I make this URL become a parameter of my Angular app? If I use ng-init to define this value, how can I use it in the socketFactory?
Thanks for your help!
louiealmeda commented
You should define the URL as a constant then inject it to your mySocket
service