In my application I have dynamic field sets on what is otherwise the same form. I can load them from the server as javascript includes and that works OK.
However, it would be much better to be able to load them from a separate API.
$.getJSON() provides a good way to load the json but I have not found the right place to do this. Clearly it needs to be completed before the compile step begins.
I see there is a fieldTransform facility in formly. Could this be used to transform vm.fields from an empty object to whatever comes in from the API?
If so how would I do that?
Thx. Paul
There is an example on the website that does exactly what you're asking about. It uses
$timeout
to simulate an async operation to load the field configuration, but you could just as easily use angular's own$http
to get the json from the server. It hides the form behind anng-if
and only shows the form when the fields return (whenng-if
resolves to true, it compile the template).