簡體   English   中英

Angular-6-JSON 模式表單錯誤:嵌套數組 getControl 錯誤:無法在 FormGroup 中找到“0”項

[英]Angular-6-JSON schema form Error: Nested Arrays getControl error: Unable to find "0" item in FormGroup

您好,我目前正在開發一個使用JSON 模式形式的項目

對具有遞歸架構引用的嵌套數組使用布局時,不斷收到以下錯誤

嵌套數組 getControl 錯誤:無法在 FormGroup 中找到“0”項。

示例: https : //stackblitz.com/edit/angular-c1mzvk

遞歸引用示例: https : //hamidihamza.com/ajsf/? set = ng-jsf & example = ng-jsf-deep-ref & framework = bootstrap-4 & language =en

如果我不提供布局或設置 layout = ['*'],該表單將完美運行。 如果我確實提供了一個,則無法呈現表單

Github問題也不走運

這是 stackbiltz 鏈接: https ://stackblitz.com/edit/angular-zvsitp

我已將架構更改為下面提到的代碼,並且在控制台中看不到任何錯誤。

schema = {
$schema: "http://json-schema.org/draft-07/schema#",
type: "object",
title: "Product Variant",
additionalProperties: false,
definitions: {
  int: {
    type: "number",
    minimum: 0,
    maximum: 10
  },
  string: {
    type: "string",
    minLength: 0
  },
  valueItem: {
    type: "object",
    properties: { value: { $ref: "#/definitions/int" } }
  },
  valueItemArray: {
    type: "array",
    items: { $ref: "#/definitions/valueItemArray" }
  },
  dtoArray: {
    type: "array",
    items: { $ref: "#/properties/staffLanguageLevelDto" }
  },

},
properties: {
  staffLanguageLevelDto: {
    type: "object",
    properties: {
      id: { $ref: "#/definitions/int" },
      staffId: {
        allOf: [
          { $ref: "#/definitions/int" },
          { maximum: 5, title: "staffId (overriden maximum)" }
        ]
      },
      languageId: {
        allOf: [
          { $ref: "#/definitions/valueItem" },
          { title: "languageId (object with custom title)" }
        ]
      },
      languageLevelId: { $ref: "#/definitions/int" },
      languageName2: {
        allOf: [
          { $ref: "#/definitions/string" },
          {
            default: "ole",
            maxLength: 3,
            title: "languageName2 (custom default & maxLength)"
          }
        ]
      },
      languageLevelName: { $ref: "#/definitions/dtoArray" }
    }
  }
}
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM