If you have a component
@Component({ selector: 'my-component' }) class MyComponent { @Input() name:string; ngOnChanges(changes) { } ngOnInit() { } }
you can use it as
<my-component [name]="somePropInParent"></my-component>
This makes the name property associated with the data.
When the value of somePropInParent been changed, Angulars changes the name discovery updates and calls ngOnChanges()
After ngOnChanges() was called for the first time, ngOnInit() called once to indicate that the initial bindings [name]="somePropInParent" ) were allowed and applied.
See https://angular.io/docs/ts/latest/cookbook/component-communication.html for details
source share