I'm trying to use the onChanges lifecycle hook which returns a SimpleChange
object. Looking inside this object, I see 2 properties: currentValue and previousValue.
I'm passing an array of numbers to this hook, and trying to use currentValue
, which shows type of Array. Here is a plunker for example. I am console logging out the object to see how to use it.
I tried checking the docs on SimpleChange but there isn't anymore information I can find.
My questions:
Is there a way to parse this array? Is it even an Array?
Am I incorrectly using this hook? I want to pass data to a custom directive which uses this data to create a chart using ng2-charts. Sort of related to this other stackoverflow answer but outside the constructor. The chart should build on data changes passed to the directive instead.
Are there alternative objects besides
SimpleChange
that I can use? Any examples from blogs or articles?Any recommended resources to look at about SimpleChange and lifecycle hooks? The docs are a bit dry, and don't have many examples.
Thanks for reading! I'm sorry but I will be heading off for the night, but will check again in the morning.