-
Notifications
You must be signed in to change notification settings - Fork 25.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic disabled in model-driven forms is way too complex/verbose #11900
Comments
Not the only way this.form.controls['val1'].statusChanges.subscribe((newStatus) => {
let val2 = this.form.controls['val2'];
if (newStatus === VALID) {
val2.enable();
} else {
val2.disable();
}
} And to recite @vicb
|
@manklu I think you got my point that this is too verbose for a simple So please be smart and try to understand the problem rather than focusing on details! In addition, I'm not asking for support, I'm asking for a feature (being able to use |
Sorry, but then you should not say
This statement is definitely false, and lead me in the wrong direction.
Then you should simply fill out the template to avoid any misunderstanding.
Have a look at #11271.
I thougth the rest is obvious |
Thanks for the reference...for the rest, I won't argue, the goal of this is not to debate but to point problems and find solutions... |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
In model-driven forms (
formBuilder
), the only way to dynamically disable an input is to define controls outside of the mainformBuilder
and then to subscribe the control that will influence the disable:This solution is extremely verbose and adds an extreme complexity when
inputs
are disabled depending on each others (imagine a cascade of disabled, we would need to register each variable!)While a much simpler way would be to add
[disabled]="this.form.controls.val1.valid"
inside the template, Angular doesn't allow to do that and throws a warning...I understand that model-driven forms are great for testing and that this way we can test the disable. However, I think that disable is mostly used as a visual indication for the user (not like validators) and in most cases it doesn't need to be tested!
What blocks us to use
disabled
in the template?The text was updated successfully, but these errors were encountered: