angular - Angular-6-JSON 模式表单错误:嵌套数组 getControl 错误:无法在 FormGroup 中找到“0”项
问题描述
您好我目前正在做一个使用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问题也没有运气
解决方案
这是 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" }
}
}
}
};
推荐阅读
- python - 在python中连接不同数据库上的2个表
- scylla - 如果正在加载数据,如何延长 scylla 节点的启动时间
- prolog - 在 Prolog 中使用对列表作为参数
- java - 我在哪里添加 public static void main(String[] args)
- javascript - 使用扩展汉堡级别的按钮创建多级汉堡菜单
- python - scipy's 8 中的 SIGSEV 故障
- javascript - 如何在光滑滑块中扩展悬停幻灯片的宽度并为第一项设置间距?
- python - 打开文件时如何使用 if / else 条件。Python
- sql - 截断 SQL 日期时间至今
- path - 使用 Final Builder 编译 Delphi 项目