Seeking a solution for storing properties needed in multiple components using a config file. For example:
number-one-component.ts
export class NumberOneComponent {
view: any[];
xAxis: number;
yAxis: number;
label: string;
labelPosition: string;
chartSize: number;
}
number-two.component.ts
export class NumberTwoComponent {
view: any[];
xAxis: number;
yAxis: number;
label: string;
labelPosition: string;
chartSize: number;
}
Attempted to create a file imported into one component and used Object.assign(this, tokenName) in the constructor. However, TypeScript raised errors about the properties not belonging to the component.
Initial approach:
chart-config.ts
export const ChartConfig = {
view: any[];
xAxis: number;
yAxis: number;
label: string;
labelPosition: string;
chartSize: number;
}
Unfortunately, this method failed. In the constructor of either component, tried:
constructor() {
Object.assign(this, ChartConfig);
}
Any advice on efficiently achieving a shared configuration file for components requiring specific properties would be greatly appreciated.