0

i tried to make custom filter in angularjs with dropdown, but it not work. this is my code. i want to pass this value from this select

<select class="form-control" ng-model="custom" >
                <option value="asd">test123</option>

into this filter

<tr ng-repeat="item in searched = (coba | filter:{{{custom}}:search}) | coba:(currentPage-1)*itemsPerPage | limitTo: viewby">

thank you

1 Answers1

0

Here is an example which may help you:

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
  $scope.names = ["John", "Hannah", "Vicky"];

  $scope.coba = [{
      name: 'John'
    },
    {
      name: 'Peter'
    },
    {
      name: 'Amy'
    },
    {
      name: 'Hannah'
    },
    {
      name: 'Michael'
    },
    {
      name: 'Sandy'
    },
    {
      name: 'Betty'
    },
    {
      name: 'Richard'
    },
    {
      name: 'Susan'
    },
    {
      name: 'Vicky'
    },
    {
      name: 'Ben'
    },
    {
      name: 'William'
    },
    {
      name: 'Chuck'
    },
    {
      name: 'Viola'
    }
  ];
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">

  <select ng-model="custom" ng-options="x for x in names">
<option value="">All</option>
</select>
  <table>
    <tr ng-repeat="item in coba|filter:custom">
      <td>{{item.name}}</td>
      <tr/>
  </table>
</div>
ferhado
  • 2,363
  • 2
  • 12
  • 35