import win32com.client
from datetime import datetime as dt
from datetime import timedelta,timezone
import pytz
import linecache
from xlrd import open_workbook
from xlutils.copy import copy
import xlwt
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
给出一个看起来像这样的myForm.value。
ngOnInit() {
this.pgForm = this.fb.group({
pgroup: ['', Validators.required],
needs: this.fb.array([this.fb.control('')]),
});
}
get needs() {
return this.pgForm.get('needs') as FormArray;
}
addNeed() {
this.needs.push(this.fb.control(''));
}
我想要一个看起来像这样的myForm.value;以便与我的API很好地配合
Values: { "pgroup": "blah", "needs": [ "blah", "blah", "blah" ]}
是否可以在formBuilder上实现?
答案 0 :(得分:1)
您将不得不拥有一个FormControl
和FormGroup
name:
的{{1}}数组:
FormControl
与添加时相同:
ngOnInit() {
this.pgForm = this.fb.group({
pgroup: ['', Validators.required],
needs: this.fb.array([this.fb.group({ need: this.fb.control('') })])
});
}
答案 1 :(得分:0)
是的,您必须将一个表单组推送到数组。
ngOnInit() {
this.pgForm = this.fb.group({
pgroup: ['', Validators.required],
needs: this.fb.array([this.fb.group({ need: [''])]),
});
}
get needs() {
return this.pgForm.get('needs') as FormArray;
}
addNeed() {
this.needs.push(this.fb.group({ need: [''] }));
}