Open skorunka opened 6 years ago
Any traction on this? Would be immensely useful.
I'm currently in need of this for our client. We've got a 2 way binding going on but all nested objects aren't copied over. I tried to use onChange and just overwrite with a deep copy, but I can't seem to get it to work properly. Any suggested workarounds?
Pulled the latest master branch down and am running locally. I see the same issue with your code / examples. The "Custom bindings" and "Other Schema" examples both have arrays of objects in the .json sample data and they're defined in the schema, yet they are not copying over. Looking to get this corrected and or help with this issue. Thanks
@jpeterson88 I have just made a simple fix for that in https://github.com/guillotinaweb/ngx-schema-form/tree/issue-191, the tests are green, but I would appreciate if you could check out this branch locally and try it out in your use case specifically before we merge it.
Thanks.
Hey @ebrehault thanks so much for quickly taking a look into this. I pulled the branch down and am still seeing the same issue. Here's the scenario I'm running, when I run the app locally, the first page to load is http://localhost:4400/json. This page has "Sample 4 - Visibility Binding" loaded. If I change the dropdown to point to "Sample 1 - General", I expect the column that has the "Model" json showing to show the category and categories fields populated as well as the form showing the values set considering the samplemodel.json file being loaded has these fields populated:
Taking it a step further, if we breakpoint this, the first time setModel is called, "value" has the values from the form, with the default values set in the schema, causing the model to be overridden.
I'm having a hard time following where value is actually coming from, but it seems that "value" should be updated, in a deep copy manner, when the bound model is updated.
Okay, so I came across issue 233. I simply changed [(model)] to [(ngModel)] and it seemed to have fixed my problem! When changing my models, everything appears to bind up appropriately :) This begs the question, why is this happening though when not flexing on angular's model binding.
you mean it works with the branch I did or on master?
It did not work with the branch you created. I had to change my binding in order for it to work.
This is deeply related to the issue #233 .
We already resumed that the binding MUST be done with [(ngModel)]
because of the buit-in emitter.
See also:
https://github.com/guillotinaweb/ngx-schema-form/issues/233#issuecomment-420704459
https://github.com/makinacorpus/angular2-schema-form/blob/29ee297ced8e157d6b5819bd88851127615255c6/src/form.component.ts#L100
Hi, I think we should do deep copy there.
We do have a model where our properties are object and in that case they are not copied on model change.