lostpacket
lostpacket

Reputation: 1401

AngularJS ng-class not working for conditions

This is very straightforward but I am not able to change the class.

I am basically verifying if the date is in correct format (DD-MMM-YYYY hh:mm:ss).

<input type="text" style="width : 80%" ng-model="startTime" ng-class="{invalid: !isValid ,valid: isValid}" />

where isValid is a scope variable which evaluates to true and false. The css class is not applied.

Here is the plnkr.

Upvotes: 1

Views: 2178

Answers (1)

Tim Withers
Tim Withers

Reputation: 12069

It is working. Inspect the element. Your bootstrap classes are overwriting it. Try this:

 .invalid {
    background-color: #FA787E !important;
  }

 .valid {
    background-color: #78FA89 !important;
}

Upvotes: 5

Related Questions