0

I am trying to filter by Date. The answer on this post worked for me by boindiil AngularJS ngTable filtering by Date

The only problem I am having is that the filter for the Date is Case sensitive. How do I make it not to be case sensitive? When you run his code and you type lowercase j or f for the date, no results are shown. You have to type exactly what it is. The Name filter is not case sensitive. you can type lowercase or uppercase it works.

Community
  • 1
  • 1
Mr Sumo
  • 51
  • 5

1 Answers1

0

You just need to add a check in your filter for lowercase as well.

Just replace

if($filter('date')(value.Date).indexOf(dateString) >= 0) {
  filtered.push(value);
}

with

var lower = $filter('date')(value.Date.toDateString().toLowerCase()).indexOf(dateString);
var normal = $filter('date')(value.Date).indexOf(dateString);

if(normal >= 0 || lower >= 0) {
  filtered.push(value);
}
Scott Sword
  • 4,648
  • 6
  • 32
  • 37
  • it is throwing an error on this line var lower = $filter('date')(value.Date.toDateString().toLowerCase()).indexOf(dateString); it says toDateString is not a function The value of my Date field is like this "2015-02-09T20:06:33.163" – Mr Sumo Apr 20 '15 at 15:55
  • Check your spelling, also review this - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString – Scott Sword Apr 20 '15 at 21:25