问题
I have arrived at a lengthy syntax iterating over data[areaId].main.points. Since the data is bound via [(ngModel)], it looks atrociously in my opinion. Something like this.
<div *ngFor="let item of data[areaId].main.points; let index = index; let ..." ...>
<input [(ngModel)]="data[areaId].main.points[index].e" ... >
<input [(ngModel)]="data[areaId].main.points[index].n" ... >
...
</div>
Usually, when the syntax gets ugly, it's a strong indication that the design sucks and should be simplified. Not always. But in most cases. So I wonder if there's a syntax setting the data-main-points thing to something locally defined and shorter. One option might be to declare an auxilliary field in the model only keeping a portion of the whole data and bind to it. However, I sense that there's a better way to approach it.
How should I simplify the expression so that the iterator can reder and the ngModel can keep an eye on its changes?
来源:https://stackoverflow.com/questions/60027413/simplifying-expression-in-iterator-biding-to-ngmodel