I\'m trying to define constants with other constants, but it seems that it can\'t be done, because the initial constant isn\'t ready when the required constant depending req
As long as you don't need access to your constant in providers, this should work fine:
.constant('HOST', 'localhost')
.factory('URL', function(HOST) { return "http://" + HOST })
If you need access to you constants in providers, then I guess you have to do some more work:
.constants('HOST', 'localhost')
.provider('DOMAIN', function(HOST) {
var domain = "http://" + HOST;
this.value = function() { return domain };
this.$get = this.value;
})
.provider("anyOtherProvider", function(DOMAINPovider) {
var domain = DOMAINProvider.value();
};
.factory("anyOtherService", function(DOMAIN) {
})