I devised a couple of interfaces to structure my data, as illustrated below:
export interface BindingItem{ [property:string] : BehaviorSubject<string>; }
export interface BindingObject{ [library:string] : BindingItem; }
Within my service file, I have a variable of type BindingObject
, and I am attempting to populate it using the following function:
private createBindingData(library:string, property:string, setting:string){
this.BindingData[library][property]= new BehaviorSubject(setting);
}
An error message in the console suggests that the value passed in as the property
argument cannot be assigned to undefined
with respect to the library
argument entered.
The targeted variable is initialized as an empty object like so:
private BindingData: BindingObject = {};
What is the correct approach for setting data in an object structured in this way?