1

How should I manage different environment settings in AngularJS projects? For example, I'd like to configure things like this different depending on whether I'm in development, test, staging or production:

  • Redirect URLs for single sign on
  • URLs for other services (especially those that support CORS or JSONP i.e. not on the same domain)

On the server side, in Django I'd use settings and local_settings or in Rails, I'd use different environment files like production.rb or development.rb. What's the best practice in AngularJS?

2

2 Answers 2

1

May be this lib https://www.npmjs.com/package/grunt-ng-constant could help u.

This question is related to How do I configure different environments in Angular.js?

Sign up to request clarification or add additional context in comments.

Comments

1

The solution we use is rather straight forward. Django (or Flask in our case) passes a variable that contain all the api urls to the template where I transform it into a global javascript variable.

I then have a constant defined in Angularjs which fetches that variable. At this point all my services use that constant to retrieve the necessary api url.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.