3

您好我目前正在做一个使用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

如果我不提供布局或设置布局 = ['*'],则表单可以完美运行。如果我确实提供了一个,它将无法呈现表单

Github问题也没有运气

4

1 回答 1

0

这是 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" }
    }
  }
}
};
于 2020-02-28T22:07:07.033 回答