3. Generic Constraints and Validations

Base on our public library web application, we take our focus first on input. Angular provides many arguments in input for data-binding, state control and validation:

Furthermore, the form has attributes for holistic state validation. We take one $invalid as an example:

<form name="bookInfo" ng-submit="addBook()" novalidate="novalidate">
  <!-- some inputs with constraints here -->
  <div>
    <button type="submit" ng-disabled="bookInfo.$invalid">
      Save
    </button>
  </div>
</form>

As lang as all input-values are valid, the value of bookInfo.$invalid will be false (bookInfo.$valid would be true), and the whole data inside of the form can be submitted.