-
-
Save cliffmeyers/534c3326952498a65ee4 to your computer and use it in GitHub Desktop.
Mock repository implementation using in memory data with $q/$timeout
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
var donutModule = angular.module('donuts', []); | |
donutModule.service('donutRepository', ['$q', '$timeout', function($q, $timeout) { | |
// get some donuts based on user requirements | |
this.fetchDonuts(size, filling, glaze, hasHole) { | |
var deferred = $q.defer(); | |
// return abitrary data after 500ms delay to simulate server call | |
$timeout(function() { | |
// sorry bro, we're sold out | |
deferred.resolve([]); | |
}, 500); | |
return deferred.promise; | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment