OnChanges

export interface OnChanges

exported from angular2/core defined in angular2/src/core/linker/interfaces.ts (line 27)

Lifecycle hooks are guaranteed to be called in the following order:

ngOnChanges is called right after the data-bound properties have been checked and before view and content children are checked if at least one of them has changed.

The changes parameter contains an entry for each of the changed data-bound property. The key is the property name and the value is an instance of SimpleChange.

Example (live example):

@Component({ selector: 'my-cmp', template: `<p>myProp = {{myProp}}</p>` }) class MyComponent implements OnChanges { @Input() myProp: any; ngOnChanges(changes: {[propName: string]: SimpleChange}) { console.log('ngOnChanges - myProp = ' + changes['myProp'].currentValue); } } @Component({ selector: 'app', template: ` <button (click)="value = value + 1">Change MyComponent</button> <my-cmp [my-prop]="value"></my-cmp>`, directives: [MyComponent] }) export class App { value = 0; } bootstrap(App).catch(err => console.error(err));

Members

ngOnChanges(changes: {[key: string]: SimpleChange})

Not Yet Documented