angularjs - based on current date- sort json data on button click -


i using angularjs developing hybrid mobile app ios , android. getting json data :

[{"eventid":101,"title":"no title","date":"9/8/2015","time":"12:00 am","location":""},{"eventid":120,"title":"my first event","date":"9/15/2015","time":"12:00 am","location":""}] 

my question have 1 button, click on button need short data based on current date. if click on button should show me record matched current date.

i tried follow link not working.

code :

 $scope.schedule = [{"eventid":101,"title":"no title","date":"9/8/2015","time":"12:00 am","location":""},{"eventid":120,"title":"my first event","date":"9/15/2015","time":"12:00 am","location":""}];    <ion-content>            <ul ng-repeat="member in schedule">             <li class="item">                 <div class="item" style="border-width: 0px; padding : 1px;">{{member.title}}</div>                  <div class="item" style="border-width: 0px; padding : 1px;">{{member.location}}</div>                 <div class="item" style="border-width: 0px; padding : 1px;">{{member.time}}{{member.date}}</div>              </li>           </ul>       </ion-content>     <ion-footer-bar align-title="left" class="bar-assertive">       <div class="list">          <a ng-click="setorder()"> show today's </a>     </div>     </ion-footer-bar> 

here's working plnkr

markup

<button ng-show="curdate == ''" type="button" ng-click="filterbycurdate()">filter current date</button> <button ng-hide="curdate == ''" type="button" ng-click="curdate = ''">clear filter</button> <table>   <thead>     <tr>       <th>eventid</th>       <th>title</th>       <th>date</th>     </tr>   </thead>   <tbody>     <tr ng-repeat="event in events | filter: {date: curdate}">       <td>{{event.eventid}}</td>       <td>{{event.title}}</td>       <td>{{event.date}}</td>     </tr>   </tbody> </table> 

controller code

$scope.curdate = ''; $scope.filterbycurdate = function() {   var = new date();   $scope.curdate = $filter('date')(now, 'm/dd/yyyy'); };  $scope.events = [...]; 

Comments