Wednesday, March 21, 2018

What does SimpleChanges at ngOnChanges do anyways?

Following up on this, this has the following example of inspecting specifically what changed at ngOnChanges with SimpleChanges:

ngOnChanges(changes: SimpleChanges) {
   for (let propName in changes) {
      let change = changes[propName];
      let curVal = JSON.stringify(change.currentValue);
      let prevVal = JSON.stringify(change.previousValue);
      console.log(curVal);
      console.log(prevVal);
   }
}

No comments:

Post a Comment