0

I am working on a SPA which defines many routes using angulars $routeProvider.

Before any routing occurs, I want to execute some asynchronous actions, especially fetching a list of localized strings used in the whole application. I therefore want to delay the routing until all those actions (which are actually promises) were resolved. If any is rejected, the application should stop and show a generic error message.

I could return some ensureInitialized() promise from the resolve parameter of the route definition, but this would require me to do it for all possible routes and lead to code duplication.

Is there any better way to achieve this? What would you propose?

1 Answer 1

1

try to bootstrap it manually with https://docs.angularjs.org/api/ng/function/angular.bootstrap

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

1 Comment

good idea, but as I am using few angular-based components (ngResource, $q, global constants like service endpoints, common services) for the initial loading, this might be problematic and would require few code changes.

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.