Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.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
Angular 循环显示未定义的数据集_Angular - Fatal编程技术网

Angular 循环显示未定义的数据集

Angular 循环显示未定义的数据集,angular,Angular,我试图显示以下数据集。这是一个错误消息列表。这是我从端点接收的结构 { "headers": { "normalizedNames": {}, "lazyUpdate": null }, "status": 400, "statusText": "Bad Request", "url": "https://localhost:5001/api/Corporates/Update/d0c71e53-bcbf-431f-84ef-6b65ac30202b",

我试图显示以下数据集。这是一个错误消息列表。这是我从端点接收的结构

{
  "headers": {
    "normalizedNames": {},
    "lazyUpdate": null
  },
  "status": 400,
  "statusText": "Bad Request",
  "url": "https://localhost:5001/api/Corporates/Update/d0c71e53-bcbf-431f-84ef-6b65ac30202b",
  "ok": false,
  "name": "HttpErrorResponse",
  "message": "Http failure response for https://localhost:5001/api/Corporates/Update/d0c71e53-bcbf-431f-84ef-6b65ac30202b: 400 Bad Request",
  "error": {
    "errors": {
      "Basics.Name": [
        "'Basics. Name' must not be empty."
      ],
      "Basics.PayrollDay": [
        "'Basics. Payroll Day' must be between 1 and 31 (exclusive). You entered 1."
      ]
    },
    "title": "One or more validation errors occurred.",
    "status": 400,
    "traceId": "|ab03ae99-4476ede23f1c7cdb."
  }
}
现在我尝试循环通过它,但得到一个未定义的

for(let i = 0; i < error.error.errors.length; i++) {
 console.log(error.error.errors[i]);
}
for(设i=0;i
完整代码

this._corpService.updateCorporate(this.model).subscribe((corp) => {
  if (corp) {
     this._loader.stop();
     this._notificationService.openNotification('Corporate successfully updated.');
      }
    }, (error) => {
     this._loader.stop();
     for(let i = 0; i < error.error.errors.length; i++) {
     console.log(error.error.errors[i]);
  }
});
this.\u corbService.updateCorporate(this.model).subscribe((corp)=>{
if(公司){
这个。_loader.stop();
此._notificationService.openNotification('Corporate successfully updated');
}
},(错误)=>{
这个。_loader.stop();
for(设i=0;i

如果你想知道为什么会发生这种情况,请

错误
是一个对象,而不是数组:

Object.entries(error.error.errors).forEach(([key, value]) => console.log(key, value))
或者,如果您真的希望使用该循环:

for (key in error.error.errors) {
  console.log(error.error.errors[key]);
}

显示完整的
error
object错误变量在哪里?我已经为相关的section@skydev
Console.log(error)
并将其添加到上面的codeerror.error.errors.length=什么是结构,看起来是错误的结构