Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call APP_INITIALIZER within angular app

APP_INITIALIZER is called on app load and nothing should render before APP_INITIALIZER is resolved or rejected

This is working fine.

But on data change, I want to reinitialize the app with selected data , and need same functionality ( i.e nothing should render before APP_INITIALIZER is resolved or rejected ) how to do it?

How to reinitialize the app with data change?

like image 878
user3050267 Avatar asked Aug 16 '26 01:08

user3050267


1 Answers

After lots of thoughts and using best practised in my mind I can conclude you to use this approach instead of using config rewrite.

First you need to rewrite your base urls like this:

http://localhost:4200/en/your/own/paths

The benefit of using this approach is when you load the config for your app you can use a country array as key value pair inside config file and push the specific country details there.

So after any component initialise you need to look into url for that country, and search that in config.country array if key of country found it used its values if not it will load the country data and pushed it.

You can implement a guard for this purpose or resolver for reusability of the code.

Let me know if it sound cool.

like image 172
AlokeT Avatar answered Aug 18 '26 16:08

AlokeT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!