2

I have the following requirement,

I have an array as customers (values such as cust1,cust2,cust3). I have textbox, in which when I enter some values it will filter the customers arraylist and displays my result (For example : if i enter cust1 in textbox, it will display cust1) If the value entered in textbox not in the arraylist (customers), i want to change textbox colour to red. Could anyone guide to do this.

My approach

<div class="container">
<h2>View 1</h2>
Name:
<br />
<input type="text" ng-model="filter.name" /> -- I want to change this textbox colour
<br/>
<ul>
<li ng-repeat="cust in customers | filter : filter.name | orderBy:name">{{cust.name}} {{cust.city}}</li>
</ul>
<br/>
User2
  • 1,293
  • 8
  • 17
user2000189
  • 479
  • 4
  • 6
  • 22
  • Check this http://stackoverflow.com/questions/15316363/how-to-display-length-of-filtered-ng-repeat-data , use ng-if to change the color – Shafeeque Jun 10 '15 at 08:07
  • 1
    It is ng-repeat only, i have edited it. But the link provided was not discussing on color change of ng-model text box, instead it is displaying the filtered result alone. – user2000189 Jun 10 '15 at 09:24