Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

two way binding with safe navigation operator

What is the best way to use two-way-binding (syntax-sugar) in Angular 2 with the safe navigation operator. I've tried the following.

<input [(ngModel)]="x?.y?.z"> 

But this is not supported.

Is there a way to use sth. like this?

like image 276
Manfred Steyer Avatar asked Mar 15 '16 16:03

Manfred Steyer


1 Answers

You can split up- and downwards-binding like

<input [ngModel]="x?.y?.z" (ngModelChange)="x?.y?.z ? x.y.z = $event : null"> 
like image 66
Günter Zöchbauer Avatar answered Oct 13 '22 16:10

Günter Zöchbauer