I ran into a serious problem how to get Key and Value of JSON object using *ngFor
and found an excellent solution here (incase this question gets marked as duplicate).
I used Pipes, however the solution seems quite inefficient as it generates the collection every time the change detector checks for changes. Ignoring the complexity and using this solution, still the problem is not solved as it iterates over the new array returned from component.
How can I used this solution to manipulate the original object?
Business Requirement: Keeping the Key/Value pair unbounded and allow the user to change them both on the frontend.
Below is the code snippet:
<tr *ngFor="let properties of matrixProperties">
<button (click)="addNewProperty(properties)">Add New Property</button>
<div *ngFor="let property of properties | keys">
<td>
<inline-editor type="textarea" [(ngModel)]="property.key"></inline-editor>
</td>
<td>
<inline-editor type="textarea" [(ngModel)]="property.value"></inline-editor>
</td>
</div>
</tr>
addNewProperty(properties) {
properties.id = 4;
properties['key'] = "value"; //adding new key/value pair
}