我有一个服务,在这个服务中我尝试禁用一个角度形式的字段:
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
}
},发布于 2015-10-02 19:55:36
如果希望属性是动态的,则必须使用expressionProperties。从技术上讲,你不必通过表达式属性来查看它,但它需要出现在表达式属性中,因为formly有一个优化,基本上就是说如果它不在那里,那么它就不会监视更改。这是一个性能优化。
在此示例中,您可以看到dynamic disabled正在工作:http://angular-formly.com/#/example/intro/codementor
https://stackoverflow.com/questions/32904449
复制相似问题