Exploring TypeScript and facing a challenge with setting properties in an Angular component. When I attempt to define properties on an object, I encounter an error message:
ERROR TypeError: Cannot set property 'ooyalaId' of undefined
Here is how I am trying to set the property:
@Input() data: Media;
options: Video;
constructor() { }
ngOnInit() {
console.log(this.data.ooyalaVideo);
this.options.ooyalaId = this.data.ooyalaVideo;
}
The structure of the Video object is as follows:
export interface Video {
ooyalaId: String;
pcode?: String;
playerBrandingId?: String;
skin?: Object;
options?: Object;
}
Although the data is being received properly, the issue seems to be that the 'options' Video object is consistently undefined without a clear reason why.