ng-class with condition
Description
The following code shows how to use
ng-class
with condition.
Example
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.js'></script>
<style type='text/css'>
.changed {<!--from ww w .ja va 2 s. c o m-->
background-color: rgb(252, 202, 202);
}
</style>
</head>
<body>
<div ng-app>
<form name="myForm">
<input name="myInput" ng-model="model"
ng-class="{changed: myForm.myInput.$dirty}">
</form>
</div>
</body>
</html>