On Friday, February 8, 2019 at 4:20:40 AM UTC-6, rohit jagannath wrote: > > My Angular 6 app has a table getting populated with back-end data(coming > as JSON). > Further, i have added a input form control of type 'text' to filter > results based on text on a particular column. Basically this filter happens > on every (keyup) event. > Now, i need to add an input form control of type 'date' to filter results > based on dates within another column of my table. > > Template markup i am using for text filtering - > > <p> > <input > #query > (keyup)="filter(query.value)" > type="text" > class="form-control" > placeholder="Search Venues by Name..."> > </p> > > Event handler i use for this filtering in my corresponding component - > > filter(query: string) { > this.filteredVenues = (query) ? > this.venues.filter(v => > v.name.toLowerCase().includes(query.toLowerCase())) : > this.venues; > } > > So, my text filtering is working fine. I need assistance to how i can do > the same filtering if i input date. Date format in my JSON looks like below, > > 2019-01-28T01:26:12.738Z > 2018-07-15T00:10:10.749Z > 2019-01-28T01:21:06.223Z > > I tried going with the same approach as above(text filtering) but the > complications i face are - > > 1. Keyup event will not trigger > 2. date format incompatibility between what i input and what is stored in > backend JSON > > Here is the code which i wrote for date filtering. I am sure there is a > lot i need to modify on the below. > > Template - > > <input > #queryDate > (keyup)="filterDate(queryDate.value)" > type="date" > class="form-control" > placeholder="Search Venues by Date..."> > > Component.ts - > > filterDate(queryDate: date) { > this.filteredVenues = (queryDate) ? > this.venues.filter(v => v.datecreated.includes(queryDate)) : > this.venues; > } > > Can anyone guide me as to how to get this working(filtering) for the above > mentioned date formats? >
-- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To post to this group, send email to angular@googlegroups.com. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.