I am trying to understand OnInit functionality in angular2 and read the documentation:
Description
Implement this interface to execute cu
When you have a component
@Component({
selector: 'my-component'
})
class MyComponent {
@Input() name:string;
ngOnChanges(changes) {
}
ngOnInit() {
}
}
you can use it like
This make name a data-bound property.
When the value of somePropInParent was changed, Angulars change detection updates name and calls ngOnChanges()
After ngOnChanges() was called the first time, ngOnInit() is called once, to indicate that initial bindings ([name]="somePropInParent") were resolved and applied.
For more details see https://angular.io/docs/ts/latest/cookbook/component-communication.html