title: AngularJS typehead conditional
body: <p>I have found this <a href="https://stackoverflow.com/questions/38829467/angular-autocomplete-with-search-filter">link</a> to create a auto search of data upon inputting a text on a textbox. I can also code like this below wrapping in a div to make a conditional statement to make a specific textbox only.</p>
  <p>Is there a way to make it shorter code?.</p>
  <blockquote>
  <p>Note: Not only the player name that I will make a auto complete search box. I have 3 fields to make each of them has different queries/datas to display.</p>
  </blockquote>
  <pre><code>    &lt;div class=&quot;form-group row&quot; ng-repeat=&quot;field in fields&quot;&gt;
          &lt;div class=&quot;col-sm-12&quot;&gt;
             &lt;div ng-if=&quot;field.fields == 'Player Name'&quot;&gt;
                &lt;input class=&quot;form-control&quot; ng-model=&quot;field$index&quot; id=&quot;{{field.fields}}&quot; ng-required=&quot;field.is_required&quot;
                 autocomplete=&quot;off&quot;
                 no-special-char ng-keyup=&quot;setFieldValue(field.fields,field$index,$index)&quot;
                 uib-typeahead=&quot;c.name for c in playerName | filter:$viewValue | limitTo:8&quot;
                 placeholder=&quot;&quot; value=&quot;&quot; onkeyup=&quot;this.setAttribute('value', this.value);&quot; /&gt;
          &lt;label class=&quot;text-label&quot;&gt;{{field.fields}}&lt;/label&gt;
         &lt;/div&gt;
  
  &lt;div ng-if=&quot;field.fields != 'Player Name'&quot;&gt;
              &lt;input class=&quot;form-control&quot; ng-model=&quot;field$index&quot; id=&quot;{{field.fields}}&quot; ng-required=&quot;field.is_required&quot; autocomplete=&quot;off&quot; no-special-char ng-keyup=&quot;setFieldValue(field.fields,field$index,$index)&quot; placeholder=&quot;&quot; value=&quot;&quot; onkeyup=&quot;this.setAttribute('value', this.value);&quot; /&gt;
               &lt;label class=&quot;text-label&quot;&gt;{{field.fields}}&lt;/label&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
           &lt;/div&gt;
  </code></pre>