Disable button if input length is less than 3

I want to disable the button if the input length is less than 3 :

<input type="text" [(ngModel)]="newListItem"> <button [disabled]="{ disabled : newListItem.length < 3 }"></button> 

But this code does not work. How can I achieve my goal?

+6
source share
1 answer

You only need to pass the expression to the disabled property, there is no need to create an object:

 <button [disabled]="newListItem.length < 3"></button> 
+8
source

Source: https://habr.com/ru/post/1013473/


All Articles