0

I need to style my input field border on the basis of input value length.

   <div  *ngFor="let o of options">         
               <input id="" type="text" [ngClass]="{{}}" placeholder="Search Value"(keyup)="search(o,$event)" />              
   </div>
naman
  • 51
  • 4

2 Answers2

0

You can add bindings to individual styles, not just classes, based on your properties/values/etc.

<div [style.border]="thing.length > 10 ? '1px solid red' : ''">
    ...
</div>
Krenom
  • 1,894
  • 1
  • 13
  • 20
0

Please refere below stack overflow answer, he has given multiple ways to add classes dynamically based on conditions (assuming you already have input value length). You can add any css to classes not just border.

https://stackoverflow.com/a/41974490/3292176

Ashok
  • 96
  • 5