Skip to content

Instantly share code, notes, and snippets.

@alex-wilmer
Last active January 15, 2016 12:36
Show Gist options
  • Save alex-wilmer/2ff92c72af4c1cb45ca8 to your computer and use it in GitHub Desktop.
Save alex-wilmer/2ff92c72af4c1cb45ca8 to your computer and use it in GitHub Desktop.
Angular Filters
function dateRange () {
return function(items, from, to) {
if (items != null) {
var inRange = [];
angular.forEach(items, function(item) {
if (from < item.created && item.created < to) {
inRange.push(item);
}
});
return inRange;
}
}
}
function beforeToday() {
return function(items) {
if (items != null) {
var filtered = [];
angular.forEach(items, function(item) {
if (item.date < new Date()) {
filtered.push(item);
}
});
return filtered;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment