I am looking to have some type of a config file that I can use to store properties that are needed in multiple components. Let me give you an 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;
}
I tried to create a file that I imported into one of the files and then do Object.assign(this, tokenName) in the constructor. Only problem was that TS complained about those properties not being part of the component.
I tried:
chart-config.ts
export const ChartConfig = {
view: any[];
xAxis: number;
yAxis: number;
label: string;
labelPosition: string;
chartSize: number;
}
That, did not work. In the constructor of either of the files, I did:
constructor() {
Object.assign(this, ChartConfig);
}
With no luck.
I would appreciate insight as to how I can do this so that I can have a configuration file to share between components that need those properties.