I have a list of transaction data that I am providing a search input so that the user has specified the transaction type and dates Can see NG-Repeat transaction in the raw JSON data is a Unix timestamp Date
field.
For display purposes, the timestamp is passed through a custom date formatting filter, converting it into a human readable format.
{{item.date | FormatDate}}
Now, in the search input, the entered words are looking at pre-filtered data instead of post-filtered data (i.e. searches on March 31 fail, but search Works required for timestamp).
In addition to creating a new dateFormatted
field in the source JSON, is there a way to search filtering instructions to see post-filtered data? Any other solution?
Thank you!
You can create a custom filter for that purpose
< Pre class = "snippet-"
var app = angular module ('app', []); {id: 3, date: 1426668529}, {id: 4, date: 1433 9 34000},];} }; {Appendix} {return}} {return} (return) Lt; item length; i ++) {var transaction date = new date (item [i] .date * 1000); search = new date (search) (TransactionDate.getYear) == search.getYear () & Transaction.Date.getMonth () == search.getMonth () and Transaction Date.getDay () == search.getDay ()) {filtered. Push - Script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"></script> & Lt; Body ng-app = "app" & gt; & Lt; Div ng-controller = "firstCtrl" & gt; & Lt; Input type = "text" ng-model = "search" /> & Lt; Br / & gt; Search for {{Search}} & lt; Hour / & gt; & Lt; H4 & gt; Punched & lt; / H4 & gt; & Lt; P ng-repeat = "Items in the data: Transactions: Search" & gt; ID: {{item.id}} | Date: {{item.date * 1000 | Date}} & lt; / P & gt; & Lt; H4 & gt; Unfiltered & lt; / H4 & gt; & Lt; P ng-repeat = "item in data" & gt; ID: {{item.id}} | Date: {{item.date * 1000 | Date}} & lt; / P & gt; & Lt; / Div & gt;
No comments:
Post a Comment