0

I want to set some user preferences in my angular app. I will get these preference from a REST api so I will need to make a http call. Once these have been fetched from the API, their values will not be modified.

What is the best practice in this case?

Can I make http calls in angular.module.value? Or use something like a provider? Or just write a service? What are the things to consider in any of these approaches?

What is the design pattern to be followed in this case?

2
  • Important question here is when gyou will use these preference, during the angular app bootstrap process? Commented Oct 20, 2017 at 7:28
  • I want to use these values on application load. So, yes. Commented Oct 20, 2017 at 16:50

1 Answer 1

1

You could create a service using the factory recipe. That will make the code a lttle cleaner and more modular.

Following that, you could put the user preferences on the $rootScope. This is a good case for a valid use of $rootScope, since your values are constants with application-wide applicability.

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

1 Comment

Thank you. I will give this a try.

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.