OnChanges

OnChanges

Stable Class

What it does

Lifecycle hook that is called when any data-bound property of a directive changes.

How to use

.

@Component({selector: 'my-cmp', template: `...`})
class MyComponent implements OnChanges {
  @Input()
  prop: number;

  ngOnChanges(changes: SimpleChanges) {
    // changes.prop contains the old and the new value...
  }
}

Class Overview

class OnChanges {
  ngOnChanges(changes: SimpleChanges