samedi 9 mai 2015

AngularJS: Display only first row on ng-repeat not first index

I have two dynamic dropdowns that display a list of data from the database, and refreshes the list on every 'branch' change:

<select id="regions" class="form-control" ng-model="formData.location" required ng-options="rg as rg.type for rg in region">
    <option value="">Choose Location</option>
</select>

<select id="branches" class="form-control" ng-model="formData.branches" required ng-options="c as c[formData.location.displayName] for c in formData.location.data | orderBy:'branch'">
    <option value="">Choose Branch</option>
</select>

displaying by ng-repeat:

<div ng-repeat="codes in response">
  <span ng-if="((codes.branch == formData.branches.alias) && (codes.taken == 0))">
  {{codes.code}}
</div>

I am trying to limit the display of each to just one using limitTo:1. The problem is, this filter only displays the first row from the table. Is there a filter that displays the first child of the displayed list, instead of the first index of the entire list from the database?

Note that the list refreshes a new list from the database each time the branch dropdown switch values.

Aucun commentaire:

Enregistrer un commentaire