Skip to content

Instantly share code, notes, and snippets.

@ryanhamley
Created April 8, 2015 15:40
Show Gist options
  • Save ryanhamley/dacc16a2dafe23a512c8 to your computer and use it in GitHub Desktop.
Save ryanhamley/dacc16a2dafe23a512c8 to your computer and use it in GitHub Desktop.
An example of adding custom functionality to an Angular $resource in order to create an action which accepts variables and a callback.
Event.getDateRange = function (start, end, cb){
var params = {
q: {
filters: [
{
name: 'occurrences',
op: 'any',
val: {
'name': 'date',
'op': 'gte',
'val': start.format('YYYY-MM-DD')
}
},
{
name: 'occurrences',
op: 'any',
val: {
'name': 'date',
'op': 'lte',
'val': end.format('YYYY-MM-DD')
}
}
]
},
results_per_page: 50
};
Event.query(params, function (data) {
cb(data);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment