Created
June 26, 2016 15:52
-
-
Save jigargandhi/44419719963e1664333e9c09ef6a5807 to your computer and use it in GitHub Desktop.
Angular custom template request provider
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
module.config(["$provide", function ($provide) { | |
$provide.decorator("$templateRequest", [ | |
"$delegate", "$q", "$templateCache",// DI specifications | |
function ($delegate, $q,$templateCache) { | |
// replace the delegate function | |
$delegate = function (tpl) { | |
var defer = $q.defer(); | |
// convert the tpl from trustedvaluetoken to string | |
if (typeof (tpl) !== "string" || !!$templateCache.get(tpl)) { | |
tpl = $sce.getTrustedResourceUrl(tpl); | |
} | |
// make proxy call and resolve the promise; | |
return defer.promise; | |
} | |
// return the modified delegate function | |
return $delegate; | |
}]); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment