title: How to only allow the numbers 0-5 in <input> fields with AngularJS?
body: <p>I have an input field like this:</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;input ng-model="newtodo.effort" ng-enter="addTodo()" type="number" min="0" max="5"
         maxlength="1" size="1" step="1" class="form-control marginBottom"
         placeholder="Aufwand" aria-describedby="basic-addon2" required&gt;&lt;/input&gt;
  </code></pre>
  
  <p><strong>JavaScript/Angular controller</strong></p>
  
  <pre><code>$scope.addTodo(todo) {
      restservice.addTodo(todo); // Does call to REST service backend
  }
  </code></pre>
  
  <p>In the input field above I only want to allow integer values 0, 1, 2, 3, 4 and 5.</p>
  
  <p><strong>Not</strong> allowed are floats (e.g. 1.4), characters (e.g. foo) and values less than 0 or bigger than 5.</p>
  
  <p>The input field may <strong>not be empty</strong>!</p>
  
  <p>As you can see I am already using HTML5 input attributes for this but I know that I cannot rely on those. Additionally I also check server-side if the values entered are valid against my restrictions. So far so good, but in order to increase usability and responsiveness of my web app I also want to validate these values in JavaScript using AngularJS. How would I do that? I know that I could implement complicated value checks in <code>$scope.addTodo(todo)</code> and then output error messages to the user if the values he/she entered weren't ok but I somehow "feel" that there is a better, easier "angularish" way using RegEx and a 1-liner? If so, please explain to me how to do this the Angular way. Thanks!</p>