javascriptangularangular8angular-formlyngx-formly

Angular-Formly - Access Model names for calculated fields with key names containing dot(.)


I have a config json with 3 fields, the 3rd field being a calculated field from data in the previous 2 fields. Now the catch here is I have dot(.) in their key names. e.g. "something.someone" When I try rendering the form I get an error showing undefined. My 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']"
            }
          },
]
}

The error is : FormBuilderComponent.html:24 ERROR TypeError: [Formly Error] [Expression "model['pushin_temperature.kiln_id']"] Cannot set property 'kiln_id']' of undefined enter image description here

Thanks in advance!


Solution

  • The above question has been clarified and solved in a github thread of ngx-formly and the link for the same : ngx-formly github