0

It's just a conceptual question as I'm writing my first app in AngularJS.

Is it a good idea / practice to embed some 'app wide' / 'global', constants / configs variables within a Angurar's service? - as it is singleton by definition?

1 Answer 1

1

Over than Angular app it is actually a good practice to externalize conf like parameters.

With Angular you can do it with "service" or "factory" functions. But the more appropriate is "constant" as it can be injected every where even in .config.

myApp.constant('CONF', function(){ var YOUR_SERVER_CONSTANTS; // your declarations return YOUR_SERVER_CONSTANTS; }) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.