Angular-Formly - 访问键名包含点 (.) 的计算字段的模型名称
Angular-Formly - Access Model names for calculated fields with key names containing dot(.)
我有一个包含 3 个字段的配置 json,第 3 个字段是根据前 2 个字段中的数据计算得出的字段。
现在要注意的是我在他们的键名中有点(。)。例如“something.someone”
当我尝试呈现表单时,出现显示未定义的错误。
我的 config_json :
{
"fieldGroupClassName": "row",
"fieldGroup": [
{
"className": "col-2",
"key": "remarks_backflow.bed",
"type": "input",
"templateOptions": {
"type": "number",
"label": "Bed",
"placeholder": "",
"required": true
}
},
{
"className": "col-2",
"key": "remarks_backflow.gas",
"type": "input",
"templateOptions": {
"type": "number",
"label": "Gas",
"placeholder": "",
"required": true
}
},
{
"className": "col-2",
"key": "remarks_backflow.diff",
"type": "input",
"templateOptions": {
"type": "number",
"label": "Difference",
"placeholder": "",
"required": true
},
"expressionProperties": {
"model['remarks_backflow.diff']":"model['remarks_backflow.bed'] - model['remarks_backflow.gas']"
}
},
]
}
错误是:
FormBuilderComponent.html:24 ERROR TypeError: [Formly Error] [Expression "model['pushin_temperature.kiln_id']"] Cannot set 属性 'kiln_id']' of undefined
提前致谢!
上述问题已经在ngx-formly的github线程中得到澄清和解决,并且
link 相同:
ngx-formly github
我有一个包含 3 个字段的配置 json,第 3 个字段是根据前 2 个字段中的数据计算得出的字段。 现在要注意的是我在他们的键名中有点(。)。例如“something.someone” 当我尝试呈现表单时,出现显示未定义的错误。 我的 config_json :
{
"fieldGroupClassName": "row",
"fieldGroup": [
{
"className": "col-2",
"key": "remarks_backflow.bed",
"type": "input",
"templateOptions": {
"type": "number",
"label": "Bed",
"placeholder": "",
"required": true
}
},
{
"className": "col-2",
"key": "remarks_backflow.gas",
"type": "input",
"templateOptions": {
"type": "number",
"label": "Gas",
"placeholder": "",
"required": true
}
},
{
"className": "col-2",
"key": "remarks_backflow.diff",
"type": "input",
"templateOptions": {
"type": "number",
"label": "Difference",
"placeholder": "",
"required": true
},
"expressionProperties": {
"model['remarks_backflow.diff']":"model['remarks_backflow.bed'] - model['remarks_backflow.gas']"
}
},
]
}
错误是:
FormBuilderComponent.html:24 ERROR TypeError: [Formly Error] [Expression "model['pushin_temperature.kiln_id']"] Cannot set 属性 'kiln_id']' of undefined
提前致谢!
上述问题已经在ngx-formly的github线程中得到澄清和解决,并且 link 相同: ngx-formly github