MCPcopy Index your code
hub / github.com/angular-ui/ui-router / compileTemplateUrl

Function compileTemplateUrl

test/angular/1.2/angular.js:6892–7004  ·  view source on GitHub ↗
(directives, $compileNode, tAttrs,
        $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext)

Source from the content-addressed store, hash-verified

6890
6891
6892 function compileTemplateUrl(directives, $compileNode, tAttrs,
6893 $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext) {
6894 var linkQueue = [],
6895 afterTemplateNodeLinkFn,
6896 afterTemplateChildLinkFn,
6897 beforeTemplateCompileNode = $compileNode[0],
6898 origAsyncDirective = directives.shift(),
6899 // The fact that we have to copy and patch the directive seems wrong!
6900 derivedSyncDirective = extend({}, origAsyncDirective, {
6901 templateUrl: null, transclude: null, replace: null, $$originalDirective: origAsyncDirective
6902 }),
6903 templateUrl = (isFunction(origAsyncDirective.templateUrl))
6904 ? origAsyncDirective.templateUrl($compileNode, tAttrs)
6905 : origAsyncDirective.templateUrl;
6906
6907 $compileNode.empty();
6908
6909 $http.get($sce.getTrustedResourceUrl(templateUrl), {cache: $templateCache}).
6910 success(function(content) {
6911 var compileNode, tempTemplateAttrs, $template, childBoundTranscludeFn;
6912
6913 content = denormalizeTemplate(content);
6914
6915 if (origAsyncDirective.replace) {
6916 if (jqLiteIsTextNode(content)) {
6917 $template = [];
6918 } else {
6919 $template = jqLite(trim(content));
6920 }
6921 compileNode = $template[0];
6922
6923 if ($template.length != 1 || compileNode.nodeType !== 1) {
6924 throw $compileMinErr('tplrt',
6925 "Template for directive '{0}' must have exactly one root element. {1}",
6926 origAsyncDirective.name, templateUrl);
6927 }
6928
6929 tempTemplateAttrs = {$attr: {}};
6930 replaceWith($rootElement, $compileNode, compileNode);
6931 var templateDirectives = collectDirectives(compileNode, [], tempTemplateAttrs);
6932
6933 if (isObject(origAsyncDirective.scope)) {
6934 markDirectivesAsIsolate(templateDirectives);
6935 }
6936 directives = templateDirectives.concat(directives);
6937 mergeTemplateAttributes(tAttrs, tempTemplateAttrs);
6938 } else {
6939 compileNode = beforeTemplateCompileNode;
6940 $compileNode.html(content);
6941 }
6942
6943 directives.unshift(derivedSyncDirective);
6944
6945 afterTemplateNodeLinkFn = applyDirectivesToNode(directives, compileNode, tAttrs,
6946 childTranscludeFn, $compileNode, origAsyncDirective, preLinkFns, postLinkFns,
6947 previousCompileContext);
6948 forEach($rootElement, function(node, i) {
6949 if (node == compileNode) {

Callers 1

applyDirectivesToNodeFunction · 0.70

Calls 15

extendFunction · 0.70
isFunctionFunction · 0.70
jqLiteIsTextNodeFunction · 0.70
replaceWithFunction · 0.70
collectDirectivesFunction · 0.70
isObjectFunction · 0.70
markDirectivesAsIsolateFunction · 0.70
mergeTemplateAttributesFunction · 0.70
applyDirectivesToNodeFunction · 0.70
forEachFunction · 0.70
compileNodesFunction · 0.70
jqLiteCloneFunction · 0.70

Tested by

no test coverage detected