Search code examples
onsen-ui

Filter on Onsen UI lazy repeat?


Is there a way to apply a search filter on an Onsen UI lazy repeat list ?

If we use for instance <input ng-model="search.$">

We can't directly apply | filter:search as it is not an ng-repeat.

Any idea ?

Thank you.


Solution

  • You need to filter the results return by the delegate object:

    Simple example:

    $scope.MyDelegate = {
      configureItemScope: function(index, itemScope) {
        itemScope.name = $scope.filteredItems[index].name;
      },
      calculateItemHeight: function(index) {
        return 44;
      },
      countItems: function() {
        return $scope.filteredItems.length;
      }
    };
    

    In this codepen a large list of countries is filtered in this way: http://codepen.io/argelius/pen/VLdGxZ