What is the best way to use two-way binding (syntax sugar) in Angular 2 using the elvis operator. I tried
<input [(ngModel)]="x?.y?.z">
But this is not supported.
Is there any way to use sth. like this?
You can split the binding up and down as
<input [ngModel]="x?.y?.z" (ngModelChange)="x?.y?.z ? xyz = $event : null">
<input [ngModel]="x?.y?.z" (keyup)="changeMe($event.target.value)"> {{x?.y?.z}} export class ParentCmp { x={y:{z:"a"}} changeMe(val) { console.log(val); this.xyz=val; } }
http://plnkr.co/edit/ZBeSPqf4HUwLOeWSNfZJ?p=preview