Within the TypeScript code, a name
variable is assigned input from another component.
@Input() name : any ;
In the ngOnChange function, I retrieve and print the SimpleChange object in the following manner.
ngOnChanges(changes: SimpleChange){
console.log(changes);
console.log(changes.currentValue);
}
The output displayed in the console is as follows. https://i.sstatic.net/MhxM5.png
I am puzzled by the fact that the console shows a string value of "Cafeteria Old Beach"
for the currentValue
property.
However, when I use
console.log(changes.currentValue)
, it returns undefined. How can I correctly access the value of the currentValue
property? Thank you in advance.