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) : void
}

Class Description

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 the changed properties.

See Lifecycle Hooks Guide.

Class Details

ngOnChanges(changes: SimpleChanges) : void

exported from @angular/core/index, defined in @angular/core/src/metadata/lifecycle_hooks.ts

doc_Angular
2016-10-06 09:46:48
Comments
Leave a Comment

Please login to continue.