Skip to content

Instantly share code, notes, and snippets.

@rcolepeterson
Last active August 29, 2015 14:08
Show Gist options
  • Save rcolepeterson/457519a610bdb471cf1b to your computer and use it in GitHub Desktop.
Save rcolepeterson/457519a610bdb471cf1b to your computer and use it in GitHub Desktop.
Angular - mock resolve
//used for stubbing out a service and returning resolve
function getImagesService() {
var serviceUrl = '';
//add fake data for testing.
if (serviceUrl === '') {
var images = [], image;
for (var i = 1; i <= 18; i++) {
var image = {
caption: "Lets party",
fullname: "cole peterson",
image_standard: "http://fillmurray.com/500/300",
image_thumbnail: "http://fillmurray.com/100/100",
username: "cole" + i
}
images.push(image);
}
var dfd = $q.defer();
//Mock resolve.
dfd.resolve({
status: 'ok',
data: images
});
return dfd.promise;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment