Components: md-input does not honor [value] expressions

Created on 23 Dec 2016  路  6Comments  路  Source: angular/components

Bug, feature request, or proposal:

When using input[md-input] and binding a value using [value]="expr", the internal value is not updated when [value] resolves. This in turn propagates to empty not updating once [value] resolves.

What is the expected behavior?

When setting an input's value with [value], it should be honored. The placeholder should move out of the way when value is set.

What is the current behavior?

The input believes it is empty and the placeholder stays in the original spot.

What are the steps to reproduce?

http://plnkr.co/edit/79XlYsdCjUKQvnKQyDRU?p=preview

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

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

Material 2.0.0-beta.0

Is there anything else we should know?

has pr

Most helpful comment

same is true when using reactive forms and not setting the values right from the start (eg set them after http call or a timeout)
http://plnkr.co/edit/JkLHwmauIhJGy7dJfQU7?p=preview

Edit: it seems that a handful of things are missing here from the NgControl because the (new) md-input directive seems just to rely on Inputs for things like 'disabled' or 'required' to style the container & label... (updated the plnkr)

All 6 comments

As a follow up, this works properly when using ngModel or formControlName. I actually have a scenario in which I want to show readonly form elements without binding the data to a form. It also does work if using value="name" but not using value="{{name}}"

same is true when using reactive forms and not setting the values right from the start (eg set them after http call or a timeout)
http://plnkr.co/edit/JkLHwmauIhJGy7dJfQU7?p=preview

Edit: it seems that a handful of things are missing here from the NgControl because the (new) md-input directive seems just to rely on Inputs for things like 'disabled' or 'required' to style the container & label... (updated the plnkr)

it also seems not to work when binding via [value]="some.value"
this causes the placeholder to remain where it was

image

it also seems not to work when binding via [disabled]="testCondition" or [disabled]= "'true'"

We still can edit the value when testCondition is true.

It doesn't work even when using formControl or formControlName, specifically when the value is set asynchronously.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

constantinlucian picture constantinlucian  路  3Comments

jelbourn picture jelbourn  路  3Comments

xtianus79 picture xtianus79  路  3Comments

savaryt picture savaryt  路  3Comments

julianobrasil picture julianobrasil  路  3Comments