Skip to content
Advertisement

Angular – @Inject(MAT_DIALOG_DATA) doesn’t allow property access

I’m injecting data of type Sequence into a modal

JavaScript

This is the interface:

JavaScript

I inject the data into the modal and I console.log it:

JavaScript

Everything is fine, data is shown in the console and I can see every value of each property. The problem resides in trying to access any of these properties. If I try to console.log any of this properties, let’s say the property announces, console.log(this.data.announces) gives undefined which doesn’t seem to make sense because console.log(this.data) gave all the data including the value of announces. There seems to be a problem with accessing the properties of the original injected data. This is the original result of console.log(this.data)

JavaScript

Needless to say that I can’t work with undefined values

Advertisement

Answer

You can simply pass your object, without wrapping it into another object.

So it would look like :

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement