Created
April 8, 2015 15:40
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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