In my Angular application, I am working with an array called subAgencies
that is connected to a datasource. I need to implement 2-way binding on this array. Currently, I have a method in place where I copy the contents of the original array to a new one, make modifications, and then re-assign it back to the original. While this approach works, I feel like it is quite verbose.
this.subAgenciesOriginal = Object.assign([], this.subAgencies);
this.subAgencies = []
this.subAgenciesOriginal.splice(this.subAgenciesOriginal.findIndex(item => item.subAgencyId === subAgencyToRemove.subAgencyId), 1)
this.subAgencies = Object.assign([], this.subAgenciesOriginal);