I have a service in which i try to disable an angular-formly field:
formField.templateOptions.disabled = true;
Even though the templateOption object is correct, the field is not disabled:
"templateOptions": {
"type": "text",
"placeholder": "",
"label": "Single Line Test",
"disabled": true
},
Is this not possible?
Thanks.
Edit: Form Code before disabling in service
{
"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
}
},
I have a service in which i try to disable an angular-formly field:
formField.templateOptions.disabled = true;
Even though the templateOption object is correct, the field is not disabled:
"templateOptions": {
"type": "text",
"placeholder": "",
"label": "Single Line Test",
"disabled": true
},
Is this not possible?
Thanks.
Edit: Form Code before disabling in service
{
"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
}
},
Share
Improve this question
edited Oct 2, 2015 at 10:42
user2298830
asked Oct 2, 2015 at 9:38
user2298830user2298830
551 gold badge2 silver badges8 bronze badges
1
- can you post the code for the form too? – Jahongir Rahmonov Commented Oct 2, 2015 at 9:48
1 Answer
Reset to default 3If you want a property to be dynamic, you must use expressionProperties
. Technically, you don't have to see it via an expression property, but it needs to be present in expression properties because formly has an optimization that basically says if it's not on there, then it won't watch for changes. This is a performance optimization.
You can see dynamic disabled working in this example: http://angular-formly./#/example/intro/codementor