Use of ng-invalid directive in style

You can use ng-invalid directive for validation.

Example: Use of ng-invalid directive in style.

<!DOCTYPE html>
<html>
     <head>
          <script src="Scripts/angular.min.js"></script>
          <style>
               input.ng-invalid
               {
                    background-color: red;
               }
          </style>
     </head>
     <body>
          <form ng-app="" name="myForm">
               Enter your name:<input name="txtName" ng-model="myTxt" required>
          </form>
          <p>If you write in the textbox, the red color will be lost.</p>
     </body>
</html>


Output:
ng invalid directive