Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 将数组附加到';formdata';如何获得服务器端?_Angularjs_Entity Framework - Fatal编程技术网

Angularjs 将数组附加到';formdata';如何获得服务器端?

Angularjs 将数组附加到';formdata';如何获得服务器端?,angularjs,entity-framework,Angularjs,Entity Framework,我正在使用FormData上传文件。我还想发送一组其他数据 当我只发送图像时,效果很好。当我在formdata中添加一些文本时,效果很好。当我尝试附加下面的“ProIList”数组时,其他一切都正常工作,但没有发送任何数组 这是我的angular.js文件代码: this.AddPro = function (file, P) { var formData = new FormData(); formData.append("file", file); formData.append("name

我正在使用FormData上传文件。我还想发送一组其他数据

当我只发送图像时,效果很好。当我在formdata中添加一些文本时,效果很好。当我尝试附加下面的“ProIList”数组时,其他一切都正常工作,但没有发送任何数组

这是我的angular.js文件代码:

this.AddPro = function (file, P) {
var formData = new FormData();
formData.append("file", file);
formData.append("name", P.name);
formData.append("description", P.description);
formData.append("ProIList", P.ProIList);  // this is array list      

var Response = $http.post("/Product/AddProduct", formData,
    {
        transformRequest: angular.identity,
        headers: { 'Content-Type': undefined }
    })
.success(function (res) {
    Response = res;
})
.error(function () {
});
return Response;
}
这是我的控制器方法:

[HttpPost]
[Route("AddProduct")]
public string AddProduct(string name, string description, IList<ProductItems> ProIList) // here i m not getting array 
{
    Products objP = new Products();            
    string Res = "";

                objP.name = name;
                objP.description = description;                       
                db.Promotions.Add(objP); // and here add product is done now want to add ProductItems table entry so how can do 
               db.SaveChanges();                  
    return Res;
}

用我的代码,我得到了所有的api方面的文件,如名称,描述,还有图像,但只是没有得到列表,所以你们能知道我的mistek在哪里吗
 [Table("ProductItems ")]
  public class ProductItems 
  {
  [Key]
  public int id { get; set; }

[ForeignKey("Products")]
public int pid {get; set;}

public int Qty { get; set; }

public Decimal Rate { get; set; }

public virtual Products Products { get; set; }
}