Opting for the constant approach can greatly benefit us, as it allows easy access to settings at the configuration level and within providers. This enables us to efficiently utilize these settings throughout our application.
When using constants, we can inject them just like we do with services/factories or other dependencies in our code.
To enhance its functionality, incorporating an Object inside the app.constant declaration would enable us to store multiple settings within it.
Constant
app.constant('configSettings', {
'baseUrl': 'http://www.baseurl.com',
'someElseSetting': 'settingValue'
//other settings can also be included.
});
Controller
app.controller('myCtrl', function($scope, configSettings){
//console.log(configSettings.baseUrl);
//you can utilize the base URL here
});