Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
191
rated 0 times [  197] [ 6]  / answers: 1 / hits: 25034  / 11 Years ago, wed, july 3, 2013, 12:00:00

What is the best place to store application configuration settings in AngularJS? This could be things like application constants, lookups etc. which could be used both from controllers and services or factories. I could create a separate service that stores and retrieves these things but I was wondering if there is another proper place to store and retrieve those.


More From » angularjs

 Answers
8

You can use the constant() provider!



app.constant('myAppConfig', {ver: '1.2.2', bananas: 6, hammocks: 3, bananaHammocks: true});


This is not a whole lot different from Terry's solution, but constants don't change so they are applied before the other providers. Also, this module can be injected into your config function.



app.config(function(myAppConfig){
console.log(myAppConfig.bananaHammocks);
});


have fun


[#77209] Wednesday, July 3, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tomas

Total Points: 165
Total Questions: 111
Total Answers: 103

Location: Maldives
Member since Tue, Dec 21, 2021
2 Years ago
tomas questions
Thu, Jan 27, 22, 00:00, 2 Years ago
Mon, May 10, 21, 00:00, 3 Years ago
Tue, Jan 5, 21, 00:00, 3 Years ago
;