angular-socket-io icon indicating copy to clipboard operation
angular-socket-io copied to clipboard

Best way to provide a socket URL as a parameter to the socketFactory

Open jlethuau opened this issue 9 years ago • 1 comments

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!

jlethuau avatar Apr 07 '16 11:04 jlethuau

You should define the URL as a constant then inject it to your mySocket service

louiealmeda avatar Apr 30 '16 11:04 louiealmeda