I have a project that generates forms based on the data that is passed in.
We support may field types but, for example, here is the input template:
<label>
{{fieldSchema.label}}
<input type="{{fieldSchema.attributes.type}}"
name="{{fieldSchema.attributes.name}}"
ng-model="model[ fieldSchema.attributes.name ]" />
</label>
This works great for flat models, however if the model is nested, it falls apart, eg:
$scope.model = {
manager: {
first_name: 'John'
}
}
$scope.fieldSchema.attributes.name = 'manager.first_name';
Is there a way to use $parse or $interpolate or something similar within the ng-model? I've seen examples on how to fetch data in this structure, but I haven't been able to find a two-way binding solution.
(Note: Using angular version 1.5.0)
Edit: Here is a plunk, hopefully this makes it more clear. http://plnkr.co/edit/4E8jlsnuy5HkCZPxSf5z?p=preview
templateis getting rendered?fieldSchema), and usingelement.html( html );ng-model-options="{ getterSetter: true }"?fieldSchema.attributes.namewith'model.'?