In my angular app, I have a URL to which I connect for retrieving some data, a CORS enabled server.
Now, so far I had it hardcoded in my javascript file:
server_url = "http://localhost:7888/api.php/json?id=2"
Now, on test and production, those URLs of course are not valid...and everytime I do a git pull it overrides my customizations.
Where would I elegantly put a config like that in an angular app?
Declare it as a constant. Assuming you have an app named
App:angular.module('App', []).constant("urls", {"server_url":"http://localhost:7888/api.php/json?id=2"});Once declared as a constant, you'd inject it as a dependency, just as you would a service.