1

Trying to filter ng-repeat and selecting an item. The filter functionality works fine, but the issue is that when I select a desired item from the filtered list I get value of the item at that position before filtering.

 <div class="list">

                  <div class="item item-input-inset">
                    <label class="item-input-wrapper">
                            <i class="icon ion-search placeholder-icon"></i>
                      <input type="text" placeholder="Search" ng-model="search.name">
                    </label>

                  </div>

                </div>
    <ion-content scroll="true" class="has-header">
        <ion-list>
            <ion-radio ng-model="choice" ng-click="selected($index)" ng-repeat="item in lstCountry  | filter:search | limitTo:listlength">
                {{item.name}} ({{item.dial_code}})
            </ion-radio>
          </ion-list> 
georgeawg
  • 48,608
  • 13
  • 72
  • 95
codegrid
  • 977
  • 2
  • 13
  • 33
  • 1
    Don't use `$index` to select an item from a filtered `ng-repeat`. As you have seen, the `$index` is a counter for the items currently displayed, not the entire collection. In your `ng-click` you should be passing the `item` instead of the `$index`. – Lex Dec 18 '18 at 14:58
  • I have already done that. Thanks – codegrid Jan 04 '19 at 14:53

0 Answers0