compileProvider.\$get
this.\$get = ['\$injector', '\$parse', '\$controller', '\$rootScope', '\$http', '\$interpolate',
function(\$injector, \$parse, \$controller, \$rootScope, \$http, \$interpolate) {
...
return compile;
}
function compile(\$compileNodes, maxPriority) {
var compositeLinkFn = compileNodes(\$compileNodes, maxPriority);
return function publicLinkFn(scope, cloneAttachFn, options) {
options = options || {};
var parentBoundTranscludeFn = options.parentBoundTranscludeFn;
var transcludeControllers = options.transcludeControllers;
if (parentBoundTranscludeFn && parentBoundTranscludeFn.$$boundTransclude) {
parentBoundTranscludeFn = parentBoundTranscludeFn.$$boundTransclude;
}
var $linkNodes;
if (cloneAttachFn) {
$linkNodes = $compileNodes.clone();
cloneAttachFn($linkNodes, scope);
} else {
$linkNodes = $compileNodes;
}
_.forEach(transcludeControllers, function(controller, name) {
$linkNodes.data('$' + name + 'Controller', controller.instance);
});
$linkNodes.data('$scope', scope);
compositeLinkFn(scope, $linkNodes, parentBoundTranscludeFn);
return $linkNodes;
};
}
function compileNodes($compileNodes, maxPriority) {
var linkFns = [];
_.times($compileNodes.length, function(i) {
var attrs = new Attributes($($compileNodes[i]));
var directives = collectDirectives($compileNodes[i], attrs, maxPriority);
var nodeLinkFn;
if (directives.length) {
nodeLinkFn = applyDirectivesToNode(directives, $compileNodes[i], attrs);
}
var childLinkFn;
if ((!nodeLinkFn || !nodeLinkFn.terminal) &&
$compileNodes[i].childNodes && $compileNodes[i].childNodes.length) {
childLinkFn = compileNodes($compileNodes[i].childNodes);
}
if (nodeLinkFn && nodeLinkFn.scope) {
attrs.$$element.addClass('ng-scope');
}
if (nodeLinkFn || childLinkFn) {
linkFns.push({
nodeLinkFn: nodeLinkFn,
childLinkFn: childLinkFn,
idx: i
});
}
});
// 执行指令的链接函数
function compositeLinkFn(scope, linkNodes, parentBoundTranscludeFn) {
var stableNodeList = [];
_.forEach(linkFns, function(linkFn) {
var nodeIdx = linkFn.idx;
stableNodeList[linkFn.idx] = linkNodes[linkFn.idx];
});
_.forEach(linkFns, function(linkFn) {
var node = stableNodeList[linkFn.idx];
if (linkFn.nodeLinkFn) {
var childScope;
if (linkFn.nodeLinkFn.scope) {
childScope = scope.$new();
$(node).data('$scope', childScope);
} else {
childScope = scope;
}
var boundTranscludeFn;
if (linkFn.nodeLinkFn.transcludeOnThisElement) {
boundTranscludeFn = function(transcludedScope, cloneAttachFn, transcludeControllers, containingScope) {
if (!transcludedScope) {
transcludedScope = scope.$new(false, containingScope);
}
var didTransclude = linkFn.nodeLinkFn.transclude(transcludedScope, cloneAttachFn, {
transcludeControllers: transcludeControllers,
parentBoundTranscludeFn: parentBoundTranscludeFn
});
if (didTransclude.length === 0 && parentBoundTranscludeFn) {
didTransclude = parentBoundTranscludeFn(transcludedScope, cloneAttachFn);
}
return didTransclude;
};
} else if (parentBoundTranscludeFn) {
boundTranscludeFn = parentBoundTranscludeFn;
}
linkFn.nodeLinkFn(
linkFn.childLinkFn,
childScope,
node,
boundTranscludeFn
);
} else {
linkFn.childLinkFn(
scope,
node.childNodes,
parentBoundTranscludeFn
);
}
});
}
return compositeLinkFn;
}
if (directive.transclude === 'element') {
hasElementTranscludeDirective = true;
var $originalCompileNode = $compileNode;
$compileNode = attrs.$$element = $(document.createComment(' ' + directive.name + ': ' + attrs[directive.name] + ' '));
$originalCompileNode.replaceWith($compileNode);
terminalPriority = directive.priority;
childTranscludeFn = compile($originalCompileNode, terminalPriority);
} else {
var $transcludedNodes = $compileNode.clone().contents();
childTranscludeFn = compile($transcludedNodes);
$compileNode.empty();
}
_.forEach(preLinkFns, function(linkFn) {
linkFn(
linkFn.isolateScope ? isolateScope : scope,
$element,
attrs,
linkFn.require && getControllers(linkFn.require, $element),
scopeBoundTranscludeFn
);
});
if (childLinkFn) {
var scopeToChild = scope;
if (newIsolateScopeDirective && newIsolateScopeDirective.template) {
scopeToChild = isolateScope;
}
childLinkFn(scopeToChild, linkNode.childNodes, boundTranscludeFn);
}
_.forEachRight(postLinkFns, function(linkFn) {
linkFn(
linkFn.isolateScope ? isolateScope : scope,
$element,
attrs,
linkFn.require && getControllers(linkFn.require, $element),
scopeBoundTranscludeFn
);
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有