0

I need to fetch the route data before application bootstraps in angular.

Something like we do in AngularJS[https://stackoverflow.com/a/16539428/6687096]

In the above link we can make normal ajax call to fetch the data from server then application will bootstrap manually.

How can we implement same mechanism in angular?

OR Is there any pre-built event to fetch the data from the server before application bootstrap. ?

OR We have to make http call from main.ts file ? If we do so how can we share the response with other components ?

Eg:

 if (environment.production) {
  enableProdMode();
}
someHttpCall().then(function(response){
platformBrowserDynamic().bootstrapModule(AppModule)
  .catch(err => console.log(err));
})

If we do something like above how to create HttpClient instance as there is NO class ?

1 Answer 1

1

I think APP_INITIALIZER can help you here.

Check this answer, it specifies all the necessary steps.

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

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.