我正在尝试从 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/
关于如何最好地解决这个嵌套问题的任何想法?非常感谢!