我正在尝试在具有函数值的对象中转换字符串。像这样
for (let i = 0; i < this.dataSource.data.length; i++) {
let control = <FormArray>this.formShipment.controls['User'];
var a;
if (this.dataSource.data[i].active == '1') {
a = true
} else {
a = false
}
var s= { 'custom_value'+i : new FormControl(a) }
let objectValue = this._formBuilder.group(s);
var b = { 'value': objectValue }
control.push(objectValue);
}
所以我尝试的是
for (let i = 0; i < this.dataSource.data.length; i++) {
let control = <FormArray>this.formShipment.controls['User'];
var a;
if (this.dataSource.data[i].active == '1') {
a = true
} else {
a = false
}
var k='{ "custom_value'+i+'" : new FormControl(a) }'
var m= JSON.parse(k)
let objectValue = this._formBuilder.group(m);
var b = { 'value': objectValue }
control.push(objectValue);
console.log(objectValue)
}
所以请帮助如何处理其中的错误。
提前致谢!