0
我想在formly onBlur事件上執行一些計算,之後想要隱藏並顯示下一個單選按鈕字段。角形formly onblur計算和隱藏/顯示字段錯誤
當我調試一切看起來不錯,但在用戶界面我無法看到正確的行爲。
首先是文本輸入,第二個字段是收音機,我也想動態設置標籤。
我錯過了什麼嗎?任何其他方式來設置?
fields [
{
"type": "moneyInput",
"key": "amtRcv",
"id" : "amtRcv",
"templateOptions": {
required: true,
label:"",
onBlur: function calcAmount($viewValue, $modelValue, scope) {
var recvAmt = $viewValue;
if(recvAmt)
{
var missingAmount = service.amnt - recvAmt;
//here trying to set the hide and label for radio field. It is getting set but not working as expected
fields[1].hideExpression = "false";
fields[1].templateOptions.label = 'So, is $' + missingAmount + ' is missing? ';
} else {
fiedls[1].hideExpression = "true";
}
}
}
},
{
"type": "radioInput",
"key": "amnt",
"id" : "amnt",
"wrapper" : "requiredField",
"templateOptions": {
required: true,
label:"",
"options": [
{
"name": "Yes",
"value": true
},
{
"name": "No",
"value": false
}
]
}
}
]
最好先修改代碼縮進 – blackmiaool
對不起,已更正。 – user2836364