Does anyone know how to bind a JSON field using dot paths in Angular 12 HTML?
For example:
//Angular
data: any = { name: 'x1', address: { city: 'xyz' } };
field: any = 'address.city';
//Html
<input [(ngModel)]="data[field]"/> //output: undefined
What is the best way to bind and display the city using dot path in JSON?
I prefer not to do it this way:
<input [(ngModel)]="data.address.city"/>
<input [(ngModel)]="data['address']['city']"/>