I'm planing to setup a mechanism like this: 1) Request the Server for a JSON object 2) The JSON Object contains a structure like this
{"type":"address","fields":[{"name":"street"},{"name":"city"}]}
Based on this object a form shall be created with two input fields (street and city) and shall furthermore bound to an angularJS model.
$scope.formData = {"type":"address","fields":[{"name":"street","value":"Main Street"},{"name":"city","value":"NYC"}]}
Is this approach realizable with AngularJS? I want to dynamically build a form (or better say the input elements bound to AngularJS model) from a JSON object and bind a model to that form.
Thanks
If I unterstand you correctly you can just bind your object directly: http://plnkr.co/edit/kZ2H5pFIibXFwkCk3zEV?p=preview
<div ng-repeat="field in data.fields">
{{field.name}}: <input ng-model="field.value">
</div>