I ran into a problem using Angular 2 ngModel binding.
plnkr
If I use ngModel to bind a value to a child component, the value is not populated by the OnInit function of the child component. Therefore, if I bind to a call to the "boundName" property, and I try to access it in OnInit, it will be zero. However, if I bind to the same value in the parent control, not using ngModel, but an input parameter, the value is available in the OnInit function.
So if my parent component creates a child component like
<my-boundcomp [(ngModel)]="name" [(inputName)] ="name" ></my-boundcomp>
And my onInit Function child components
public ngOnInit() {
console.log("Input Name :" + this.inputName);
console.log("Bound Name :" + this.boundName);
this._boundNameOnInit = this.boundName;
this._inputNameOnInit = this.inputName;
}
. , , FormsModule ngModel, , , .
plnkr https://plnkr.co/edit/Im5oz7q1HhG5MgGTTZ1R?p=preview