I'm trying to write my own query/filter function for my AngularJs app.
I have a JSON with a lot of posts like this
[
{
"date": "20100101",
"keyword": "blah",
"header": "My header",
"text": "aaa, bb, c, dd. ee f g h."
},
{
"date": "20110101",
"keyword": "blah-hah",
"header": "Your header",
"text": "foo and bar and then some"
}
]
In my app I have a small form where the user enters "date from", "date to", and then optionally a keyword.
<input type="text" class="form-control" ng-model="dateFrom">
<input type="text" class="form-control" ng-model="dateTo">
<input type="text" class="form-control" ng-model="keyword">
The user add his/her criteria and push a button, my fabolous function loops through the JSON and all posts with a date between the criterias (if entered), and a matching keyword (if entered), will have their "text" property added to a string, bound to textarea for show.
To me, it looks like a simple loop where I check the given criterias, but how do I handle the date comparsion in a sane way? using Date.Parse()? Or are there any Angular helpers?
Regards