我正在尝试从JSON对象动态构建表单,该对象包含表单元素的嵌套组:
$scope.formData = [
{label:'First Name', type:'text', required:'true'},
{label:'Last Name', type:'text', required:'true'},
{label:'Coffee Preference', type:'dropdown', options: ["HiTest", "Dunkin", "Decaf"]},
{label: 'Address', type:'group', "Fields":[
{label:'Street1', type:'text', required:'true'},
{label:'Street2', type:'text', required:'true'},
{label:'State', type:'dropdown', options: ["California", "New York", "Florida"]}
]},
];
我一直在使用ng-switch块,但是它对于嵌套项变得站不住脚,就像上面的Address对象一样。
这是小提琴:http : //jsfiddle.net/hairgamiMaster/dZ4Rg/
关于如何最好地解决此嵌套问题的任何想法?非常感谢!