Skip to content

Md-Input Bug - When using reactive forms, setting control to disabled does not work #1880

Closed
@qdouble

Description

@qdouble

Bug, feature request, or proposal:

[x] Bug

What is the expected behavior?

You should be able to set the form control to disabled without setting the attribute in the HTML code (as angular complains if you set the disabled attribute when using reactive forms)

What is the current behavior?

It just silently fails to disable the control.

What are the steps to reproduce?

Just set the control to disabled when creating it or at any other time.
Reproduction here: http://plnkr.co/edit/RQBaGGe1p1jIBMv79Kgo?p=preview

What is the use-case or motivation for changing an existing behavior?

If you try to set disabled property using the attribute instead, angular will give a warning/error:

reactive_errors.js:30 
      It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true
      when you set up this control in your component class, the disabled attribute will actually be set in the DOM for
      you. We recommend using this approach to avoid 'changed after checked' errors.
       
      Example: 
      form = new FormGroup({
        first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),
        last: new FormControl('Drew', Validators.required)
      });

Which versions of Angular, Material, OS, browsers are affected?

Angular - 2.2.0
Material - Alpha-10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions