Answering the second part of the question:
The objective is to allow users to modify text within labels in the HTML by making changes in a constants/json/properties file instead of directly editing the HTML files. This way, any modifications made in the constants file will automatically update the text across all applicable HTML pages. For instance, {{lblManage}} could be defined as lblManage = "Manage Ta" in another file.
As previously suggested, constants can be declared in the environment.ts file and if dynamic updates are required, the store concept can be employed. Variables stored in the environment file can be managed through the store and updated as needed.
Reducer file:
export interface ConstantState {
url: any
}
export const initialState: ConstantState = {
url:'http://hello.com'
}
export function constantReducer(
state: ConstantState = initialState,
action: ConstantAction
): BookingState {
switch (action.type) {
case 'GET_STATE': {
state = {
...state,
};
break;
}
case 'SET_STATE': {
return {
...state,
url: action.payload
};
break;
}
}
return state;
}
Action FILE
import { Action } from '@ngrx/store';
export enum ConstantActionTypes {
GetConstant = '[Constant] Get',
SetConstant = '[Constant] Set'
}
export class GetConstant implements Action {
readonly type = ConstantActionTypes.GetConstant;
}
export class SetConstant implements Action {
readonly type = ConstantActionTypes.SetConstant;
constructor(payload: any){}
}
export type ConstantAction = GetConstant | SetConstant;
Create a selector:
const getConstantState = createFeatureSelector('constantState');
This allows us to dispatch actions on the required page when updating constants, and retrieve values using the selector method.
It's important to note that constants are immutable, so naming conventions should reflect this limitation.