angular - Formly 中的自定义模型
问题描述
是否有可能有一个定制的正式模型?
例如,对于以下正式配置:
[
{
"key": "g1",
"type": "repeat",
"fieldArray": {
"fieldGroup": [
{
"key": "a",
"type": "repeat",
"fieldArray": {
"fieldGroup": [
{
"type": "textarea",
"key": "ta1"
}
]
}
}
]
}
},
{
"key": "ta2",
"type": "textarea"
}
]
相应的正式模型是这样的:
{
"g1": [
{
"a": [
{ "ta1": "value for a index 0, ta1 index 0" },
{ "ta1": "value for a index 0, ta1 index 1" },
{ "ta1": "value for a index 0, ta1 index 2" }
]
},
{
"a": [
{ "ta1": "value for a index 1, ta1 index 0" },
{ "ta1": "value for a index 1, ta1 index 1" },
{ "ta1": "value for a index 1, ta1 index 2" }
]
}
],
"ta2": "value for ta2"
}
我想有与每个节点关联的自定义 ID,尤其是对于数组节点。我需要将数组中的字段与外部模型相关联,并且由于正式不保留数组项的 ID,因此在许多情况下很难找到哪些数组项已被删除/修改。
我想将正式模型存储为这样的东西
{
"g1": {
"children": [
{
"id": "a1",
"key": "a",
"children": [
{ "id": "a1.v1", "ta1": "value for ta1 index 0" },
{ "id": "a1.v2", "ta1": "value for ta1 index 1" },
{ "id": "a1.v3", "ta1": "value for ta1 index 2" }
]
},
{
"id": "a2",
"key": "a",
"children": [
{ "id": "a2.v1", "ta1": "value for ta1 index 0" },
{ "id": "a2.v2", "ta1": "value for ta1 index 1" },
{ "id": "a2.v3", "ta1": "value for ta1 index 2" }
]
}
]
},
"ta2": "value for ta2"
}
请让我知道这是否可能。谢谢!
解决方案
推荐阅读
- docker - 为什么我的 Haskell 程序不能在带有 Alpine 或 Scratch 的 Docker 中运行?
- excel - 使用 VBA 单击 javascript 链接,出现“需要对象”错误
- java - gson 对象往返 json 导致异常
- php - 在 MAMP Pro 中安装 PHP ZIP 扩展
- python - 更改列表中特定元素的类型 - python
- google-apps-script - 从 gmail 正文中提取行+列到电子表格
- c++ - 为什么 QProcess::readAllStandardOutput 读取不是所有的输出通道?
- python - 从递归嵌套的字段列表创建部分字典
- qliksense - Data Loader 脚本中的 Qlik Sense 语法
- appium - 无法在真实设备上安装集成应用程序