Reed
Reed

Reputation: 1642

Angular evaluating directive from template referenced input

I would expect the simple code to result in the button being disabled until the text length is no longer less than 3. However it does not seem to evaluate correctly as it stays disabled regardless of the input.

<input type="text" #myTextInput>
<button [disabled]="myTextInput.value.length < 3">Click me</button>

Upvotes: 0

Views: 45

Answers (1)

xrobert35
xrobert35

Reputation: 2556

This code could work, but since no event are sent, angular is not trying to check any change on the page. You can for exemple add (change)="aUselessMethod()" to your input and you will see that the code is working as expected.

Anyway I can't see a situation where you will need to get the input value like this.

Upvotes: 1

Related Questions