代码:
let options = new RequestOptions({ headers: headers });
let array1;
array1 = [{ "subfolder_name": subfolder, "file_upload": file }];
let formData: FormData = new FormData();
formData.append("folder_name",folder );
formData.append("counselor",array1 );
它返回顾问:[对象]
答案 0 :(得分:1)
FormData
是构造键值对集合的接口,因此,它不支持任何类型的嵌套结构,但是,您可以表示嵌套在键中,如下所示:
let array1 = [{ "subfolder_name": "foo", "file_upload": "bar" }];
let formData = new FormData();
formData.append('counselor[0].subfolder_name', array1[0].subfolder_name );
formData.append('counselor[0].file_upload', array1[0].file_upload );
for (let pair of formData.entries()) {
console.log(pair[0] + ': ' + pair[1]);
}