I want to disable button if input length is less than 3:
<input type="text" [(ngModel)]="newListItem">
<button [disabled]="{ disabled : newListItem.length < 3 }"></button>
But this code doesn't work. How can I achieve my goal?
You only need to pass an expression to disabled
property, there's no need to create object:
<button [disabled]="newListItem.length < 3"></button>