Is input dirty

Description

The following code shows how to check if an input element is dirty.

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 w  ww . ja v a 2s.  co  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>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities