title: Use Angular.js to validate a large list of textfields
body: <p>I have a Grails 2.3 application which generally uses jQuery for its dynamic/validation needs, but I want to evaluate if I can use Angular.js in some places.</p>
  
  <p>The exact use case I want to start with is as follows:</p>
  
  <ul>
  <li>There is a page which shows a large list of editable textfields (<code>g:textField</code>), which are pre-populated from a received Command Object and get submitted data-bound back using Grails means (e.g., <code>name="items[$i].someValue"</code>) in a Command Object.</li>
  <li>It needs to be checked that a) no two fields input are identical b) no field is the same as is already present in the database</li>
  <li>I have a JSON web service taking an item and returning whether such an item already exists in the database</li>
  <li>If an item with the same value is found on form or in database, disable submit and show a warning message to user (next to the field)</li>
  </ul>
  
  <p>Now, were this jQuery I would assign an <code>onchange</code> handler on each textbox, who would select all the other textboxes, check if any match the one just changed, and also submit a $.ajax request to invoke the JSON web service with an async callback to do the same.</p>
  
  <p>What is the proper Angular.js way for this?</p>
  
  <p>Is there one, considering I'm interested in only this validation use case, as opposed to rewriting the whole page (which works fine already)?</p>
  
  <p>So far I have added a <code>ng-model="item"</code> to the inputs, leading for all of them to be databound together, because of course that refers to just one model element <code>item</code>; then I tried some feeble attempts at array indexing to have them all be stored in some Angular array, but that failed.</p>
  
  <p>I'm mostly looking for validation that the whole limited usage scenario makes sense, and pointers to documentation on how to databind to an Angular array from controls which weren't generated by Angular (but were already there generated by a Grails <code>g:each</code>).</p>