I'm looking for a way to have a button that, when clicked, will sort a table by today's date in angularjs. This is the view page in my Angular project.
<div class="form-inline has-feedback filter-header">
<input type="text" class="form-control" placeholder="Search" ng-model="search.$" />
<!-- <i class="glyphicon glyphicon-search form-control-feedback"></i> -->
<button class="btn btn-default btn-sm" ng-click="hideFilter=!hideFilter">Advanced Search</button>
</div>
<a class="btn btn-default btn-sm pull-right" href="/#/add">Add New</a>
</div> <!-- Grid filter ends -->
<table class="table table-striped table-condensed table-responsive table-hover">
<thead class="data-grid-header">
<!-- table header -->
<tr>
<th>
<span class="fa fa-th-large"></span>
<a href="" ng-click="orderByField='title'; reverseSort = !reverseSort">Title</a>
</th>
<th class="hidden-xs">
<span class="fa fa-calendar"></span>
<a href="" ng-click="orderByField='startDate'; reverseSort = !reverseSort">Schedule Date</a>
</th>
</tr>
<!-- table filter -->
<tr ng-hide="hideFilter">
<th><span ng-hide="hideFilter"><input type="text" ng-model="search.title"></span></th>
</tr>
</thead>
<tbody class="data-grid-data">
<tr ng-repeat="visit in visitsList | filter: dateRange | filter: search |orderBy:orderByField:reverseSort">
<td>{{visit.title}}</td>
<td>{{visit.startDate | date:medium}}
</tr>
</tbody>
</table>
I need help figuring out how to set up the controller to sort by the current date. Any assistance would be greatly appreciated. Thanks in advance.