Angular - how to set controls values programatically


I am using jsonforms with Angular and can’t find an easy way to set values of all controls afer re-rendering the form. I tried using setData method of jsonformsService and when, after initializing it, I take a look at state - data is updated, but controls seem empty, no values are shown. Refreshing the form after did not help. Is there something I’m missing?

Best regards,

Hi @Pawel,

are you using the latest versions of JSON Forms (i.e. one of the 3.0.0-beta.X versions)? If yes, then you should be invoking JSON Forms via its root component which offers an @Input data. So all you need to do is to hand over a new data prop there.

Note that it actually needs to be a new object instance as we otherwise bail out of performance reasons. A convenient way to create such a new instance automatically if you only want to update a single deeply nested attribute is to use lodash’s fp/set.