javascript - AngularJS date filter in range by two inputs -
i want display data in range of date
2 inputs of date
. (angularjs date filter in range 2 inputs)
here code
var app = angular.module('app',[]).controller('ctrl1', function($scope){ $scope.record = [ {uniqueid : 'pp-12', name : 'jim', status : 'approved', date:'05/01/2015' }, {uniqueid : 'pp-11', name : 'jim', status : 'canceled', date:'05/02/2015' }, {uniqueid : 'pp-45', name : 'nick', status : 'pending', date:'05/03/2015' }, {uniqueid : 'pp-32', name : 'thomas', status : 'canceled', date:'05/04/2015' }, {uniqueid : 'pp-01', name : 'thomas', status : 'pending', date:'05/05/2015' }, {uniqueid : 'pp-09', name : 'nick', status : 'approved', date:'05/06/2015' }, {uniqueid : 'pp-23', name : 'lina', status : 'requested', date:'05/07/2015'}, {uniqueid : 'pp-39', name : 'jim', status : 'pending', date:'05/08/2015' } ]; }); <input type="text" class="form-control" name="to" ng-model="to"> <input type="text" class="form-control" name="from" ng-model="from"> <table border="1"> <thead> <tr> <td>unique id</td> <td>name</td> <td>status</td> <td>date</td> </tr> </thead> <tbody> <tr ng-repeat="data in record"> <td> {{data.uniqueid}}</td> <td> {{data.name}}</td> <td> {{data.status}}</td> <td> {{data.date}}</td> </tr> </tbody> </table>
thanks advance.
you can define custom filter purpose filters record array , returns array entries between given dates:
.filter('daterange', function() { return function(records, from, to) { return records.filter(function(record) { return record.date >= && record.date <= to; }); } }) <tr ng-repeat="data in record | daterange : : to">
plunker: http://plnkr.co/edit/smpnadty3vpmdcuw20bt?p=preview
ps: should add track record.uniqueid
ng-repeat
.
Comments
Post a Comment