-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular: Read settings from Json files #4386
Comments
Hi @rachanee-mwp, We cannot read settings from JSON files instead of environment files, because as described here this is the default and common way of getting application setup in Angular. There is also a request to ABP backend at application start, which receives specific application configuration for a user. If those two do not resolve the requirement in your case, you can use one of Angular's predefined tokens and make an Http request within the token factory. After getting the configuration, you can keep it in a singleton service or pass it to a state for further use. Please take a look at this article on using an APP_INITIALIZER token. The most common one is the APP_INITIALIZER, but depending on the scenario, PLATFORM_INITIALIZER or APP_BOOTSTRAP_LISTENER may prove to be a better choice. I wish that answers your question. Please let me know if all is clear. Have a nice day. |
Hi @armanozak Thanks for clarifying and giving list of potential solutions. |
Hi @rachanee-mwp, Looking for same tools you have in ASP.NET Zero is perfectly understandable. We will consider this as a feature request and will have to discuss if/when/how we should implement such a feature. I have marked this issue as a feature and added it to the backlog. Yet, since there already is an easy way to do that yourself, I expect this feature to be considered as a relatively low priority one compared to other issues on our roadmap. If, in the meantime, you come up with a solution that the whole community can benefit from, please do share with us. As long as it suits public use and does not break the current structure of the project, we would most certainly welcome your PR. Thanks for your contribution. |
Thanks for considering this as a future feature. Actually, I have tried to implement the APP_INITIALIZER in AbpCommercial by changing apis.default.url but Abp components are not using the new value. They still connect to the Api URL specified in environment.ts. |
related #3536 |
I created something that reads from a json file Its not a production quality implementation but it does the job. The process is roughly as below (works with ABP v3.0.x):
|
Please modify Angular modules to read settings from Json files instead of environment.ts to allow overwriting settings in CD process, for instance change API Url per deploying environment.
We saw the implementation of AppPreBootstrap which load settings from Json in ASP.NET Zero and tried to implement the logic in AbpCommercial but could not make it work somehow.
The text was updated successfully, but these errors were encountered: