我有一个基于所传入的数据生成表单项目绑定嵌套对象
我们支持可能字段类型,但是,例如,这里是input
模板:
<label>
{{fieldSchema.label}}
<input type="{{fieldSchema.attributes.type}}"
name="{{fieldSchema.attributes.name}}"
ng-model="model[ fieldSchema.attributes.name ]" />
</label>
这对于平板机型的伟大工程,但如果模型嵌套,它分崩离析,如:
$scope.model = {
manager: {
first_name: 'John'
}
}
$scope.fieldSchema.attributes.name = 'manager.first_name';
是否有使用方式$parse
或$interpolate
或类似的ng-model
?我见过如何在这个结构中获取数据的示例,但我一直无法找到双向绑定解决方案。
(注:采用了棱角分明的版本1.5.0)
编辑:这里是一个普拉克,希望这使得它更加清晰。 http://plnkr.co/edit/4E8jlsnuy5HkCZPxSf5z?p=preview
我可以知道你的输入模板是如何渲染的吗? –
我正在抓取一个HTML模板(基于'fieldSchema'中的内容),并使用'element.html(html);' –
根本不清楚具体问题是什么。演示会帮助 – charlietfl