At times, the model abstraction may fall short, leading to the necessity of synchronizing two different models.
For instance, I have two lists linked by an angular sortable, which requires a model structure like this:
left = [{name:"one"}, {name:"two"}];
right = [{name:"three"}];
However, I also want to provide the option for users to configure this using a list of checkboxes (implemented with the angular input.checkbox
directive). This would result in a model like:
elements = [{
name:"one",
position:"left"
}, {
name:"two",
position:"left"
}, {
name:"three",
position:"right"
}]
In order to effectively connect the views to corresponding controllers, there needs to be some form of data view reflection from the same higher level model. Alternatively, there is a need for two models that can stay synchronized with each other.
This concept is reminiscent of having a computed property in the same model, but commonly the suggested solution involves using a function, which does not offer two-way binding on the data returned by the function.
Essentially, what is required here is functionality similar to that of filters - maintaining a transformed version of data in alignment with the original dataset.
How could one go about resolving such a dilemma?