如何使用具有数据数组的数据创建表单组。还如何保存绑定到该数据?
数据格式
{
id: 0,
tenantId: 0,
qty: 0,
dateInvoiced: '',
status: '',
services:
{
service1: false,
service2: false,
service3: false,
otherServices: '',
}
}
如何使用服务数组创建表单组?
var group: FormGroup = new FormGroup({
id: new FormControl(''),
tenantId: new FormControl(''),
qty: new FormControl(''),
dateInvoiced: new FormControl(''),
status: new FormControl(''),
services: new FormControl(''), //how to do services array here?
});
this.dynamicFormGroup = group
如何将服务中的数据保存在最上面?谢谢
<mat-slide-toggle formControlName="services.service1">Service 1</mat-slide-toggle>
<mat-slide-toggle formControlName="services.service2">Service 2</mat-slide-toggle>
<mat-slide-toggle formControlName="services.service3">Service 3</mat-slide-toggle>