Created
November 6, 2014 18:24
-
-
Save anonymous/4eacf74771c7b1e87638 to your computer and use it in GitHub Desktop.
One path returns a promise and the other a value
This file contains hidden or 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 saved_options = {}; | |
function getOptions(myOption){ | |
if(saved_options[myOption]){ | |
return saved_options[myOption] | |
} | |
var deferred = $q.defer(); | |
$http({method: 'GET', url:'someUrl'}).then(function(data){ | |
saved_options[myOption] = data.data; | |
deferred.resolve(data.data); | |
}); | |
return deferred.promise; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment