Open Closed

Angular Environment settings replaced by settings in server side appsettings.json #91

wazbek created


Would it be possible to move the settings in the environment.ts file to the appsettings.json file in the HttpApi.Host project.

I am aware of how to add custom settings using the ISettingDefinitionContext etc. I am able to see those settings in the ConfigState:setting variable when running my angular apps. Is possible to replace the ConfigState:environment state with the settings from appsettings.json file and if so how would I go about doing this?

The reason I want to do this is to avoid having to build my angular apps for different environments and be able to control the settings in a file that I can modify at runtime. ie appsettings.json which will handle different settings for different environments using transforms.



3 Answer(s)
  • 0
    Mehmet created
    Support Team

    Hi Warick,

    Can you explain a little more detail by giving an example?

  • 0
    wazbek created

    Hi Mehmet

    Yes no problem.

    I would like to remove these from the environment.ts file in my angular application.

    application: {
        name: 'Test'
      oAuthConfig: {
        issuer: 'https://localhost:44373',
        clientId: 'Test_App',
        dummyClientSecret: '1q2w3e*',
        scope: 'Test',
        showDebugInformation: true,
        oidc: false,
        requireHttps: true
      apis: {
        default: {
          url: 'https://localhost:44373'
      localization: {
        defaultResourceName: 'Test'

    Add them to the appsettings.json in the HttpApi.Host project where I can control the values with transforms and have all application settings in one place.

    Then when my angular app starts up it loads those values from the ConfigState:settings rather than from the environment.ts file.

    I see the environment settings get passed into the CoreModule like this.

          requirements: {
            layouts: [...LAYOUTS]

    Would it be possible to somehow get the settings from ConfigState and completely replace the environment settings before passing it to the CoreModule above?

  • 0
    Mehmet created
    Support Team

    apis property is required for app initialization.

    There is an action named SetEnvironment to replace environment on runtime. See the usage below:

    import { SetEnvironment } from '@abp/ng.core';
    //... SetEnvironment(new environment data here))