【发布时间】:2026-02-05 16:20:04
【问题描述】:
我很困惑如何使用 ngx-formly 为我的表单进行布局。例如,我有 2 个字段组:General 和 Dynamic。
如何指定将军在一个 div 中,而在一个下拉列表(div)内的另一个 div 中动态?
官方示例如下: 包装器:
<div class="card">
<h3 class="card-header">{{ to.label }}</h3>
<div class="card-body">
<ng-container #fieldComponent></ng-container>
</div>
</div>
组件:
fields: FormlyFieldConfig[] = [
{
key: 'firstName',
type: 'input',
templateOptions: {
required: true,
type: 'text',
label: 'First Name',
},
},
{
key: 'address',
wrappers: ['panel'],
templateOptions: { label: 'Address' },
fieldGroup: [{
key: 'town',
type: 'input',
templateOptions: {
required: true,
type: 'text',
label: 'Town',
},
}],
},
];
这里 <ng-container #fieldComponent></ng-container> 没有具体说明它是哪个字段
【问题讨论】:
标签: angular forms ngx-formly