Angular 5 String Constant Externalisation

120 Views Asked by At

Current behaviour

We are trying load string label constants based on some criteria, So that it can be configurable without build and code modification.

Expected behaviour

Should provide some configuration files outside of an app folder, based on the criteria, fetch the specific label configurations and the app should load after getting the configuration file.

We need to have some configurations like the example described below.

app.component.html
<i class="fa fa-calendar"></i>{{labelConstant.TEST_LABEL}}

app.component.ts
export class AppComponent {
    labelConstant = LabelConfig.getLabels();
}

college.json
{
    "TEST_LABEL" : "Internal Assessment Configuration"
}

school.json
{
    "TEST_LABEL" : "Unit Test Configuration"
}
1

There are 1 best solutions below

0
On

app.component.html {{labelConstant.TEST_LABEL}}

app.component.ts export class AppComponent { Label_Constant = LabelConfig.getLabels(); }

Highlighted variable are not same