Skip to content

Instantly share code, notes, and snippets.

@benmj
Created June 19, 2014 23:12
Show Gist options
  • Save benmj/9c8670f4819f647ae3b0 to your computer and use it in GitHub Desktop.
Save benmj/9c8670f4819f647ae3b0 to your computer and use it in GitHub Desktop.
function getTemplateAsync (templateName) {
var dfd = $q.defer();
var template = $templateCache.get(templateName);
if (!template) {
$http.get(templateName).success(function (data) {
$templateCache.put(templateName);
dfd.resolve(data);
});
} else {
$timeout(function () {
dfd.resolve(template);
});
}
return dfd.promise;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment