How implement dynamic required for ng-repeat in angularjs?

49 Views Asked by At

Let say that there is a collection with key-value content. A user can edit values and keys. But when user clicks Save button server can return that collection should contain some required key-values. The question - how to do this effectively?

At first glance it needs just to merge names collection from server into already loaded. But this leads to changing content and after user click Cancel he views modified collection which actually should not be modified

Also calls simulateServerValidation (see jsfiddle example) during page loading is not a solution because key-values can be added/removed during editing or user can load page now and start (or finish) editing some minutes later.

For me the main problem is to render/add new key without object modification. E.g. if server return new keys, angular draw new inputs, then user simply can click Cancel and see non edited values. But when he needs to edit he just fill new inputs. How to do that?

jsfiddle

0

There are 0 best solutions below