我有一项服务,我尝试禁用 angular-formly 字段:
formField.templateOptions.disabled = true;
即使 templateOption 对象是正确的,该字段也不会被禁用:
"templateOptions": {
"type": "text",
"placeholder": "",
"label": "Single Line Test",
"disabled": true
},
这不可能吗?
谢谢。
编辑:在服务中禁用之前的表单代码
{
"type": "input",
"key": "single_line_test",
"templateOptions": {
"type": "text",
"placeholder": "",
"label": "Single Line Test"
},
"data": {},
"validation": {
"messages": {},
"errorExistsAndShouldBeVisible": false
},
"id": "formly_2_input_single_line_test_3",
"name": "formly_2_input_single_line_test_3",
"formControl": {
"$validators": {},
"$asyncValidators": {},
"$parsers": [],
"$formatters": [
null
],
"$viewChangeListeners": [],
"$untouched": true,
"$touched": false,
"$pristine": true,
"$dirty": false,
"$valid": true,
"$invalid": false,
"$error": {},
"$name": "formly_2_input_single_line_test_3",
"$options": null
}
},