Skip to content

Instantly share code, notes, and snippets.

@mwadams
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwadams/fc1837812817526ba854 to your computer and use it in GitHub Desktop.
Save mwadams/fc1837812817526ba854 to your computer and use it in GitHub Desktop.
app.config(["$provide", function ($provide) {
$provide.decorator("$templateCache", ["$delegate", "templateRepository", function ($delegate, templateRepository) {
// Stash away the original get method
var origGetMethod = $delegate.get;
// Replace it with our getter
$delegate.get = function (url) {
// Do we match our content type family prefix?
var prefix = 'application/vnd.endjin.test';
if (url.slice(0, prefix.length) == prefix) {
return templateRepository.getTemplate(url);
}
// Otherwise, use the original get method
return origGetMethod(url);
};
return $delegate;
}]);
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment