Javascript 在AngularJS中,什么是第一个,ng include或ng repeat?
如果我有一个模板,里面有ng repeat,并且包含了ng include,那么会发生什么呢?Javascript 在AngularJS中,什么是第一个,ng include或ng repeat?,javascript,angularjs,Javascript,Angularjs,如果我有一个模板,里面有ng repeat,并且包含了ng include,那么会发生什么呢? 将包括已完成ng重复的模板,或未完成ng重复的模板(包括ng重复后将完成)?ngInclude指令首先将从模板返回的html附加到html DOM。 然后它编译它的内容 正如您在ngInclude的源代码中所看到的 // This directive is called during the $transclude call of the first `ngInclude` directive. //
将包括已完成ng重复的模板,或未完成ng重复的模板(包括ng重复后将完成)?ngInclude指令首先将从模板返回的html附加到html DOM。 然后它编译它的内容 正如您在ngInclude的源代码中所看到的
// This directive is called during the $transclude call of the first `ngInclude` directive.
// It will replace and compile the content of the element with the loaded template.
// We need this directive so that the element content is already filled when
// the link function of another directive on the same element as ngInclude
// is called.
var ngIncludeFillContentDirective = ['$compile',
function($compile) {
return {
restrict: 'ECA',
priority: -400,
require: 'ngInclude',
link: function(scope, $element, $attr, ctrl) {
if (/SVG/.test($element[0].toString())) {
// WebKit: https://bugs.webkit.org/show_bug.cgi?id=135698 --- SVG elements do not
// support innerHTML, so detect this here and try to generate the contents
// specially.
$element.empty();
$compile(jqLiteBuildFragment(ctrl.template, document).childNodes)(scope,
function namespaceAdaptedClone(clone) {
$element.append(clone);
}, {futureParentElement: $element});
return;
}
$element.html(ctrl.template);
$compile($element.contents())(scope);
}
};
}];
看那些排
$element.html(ctrl.template);
$compile($element.contents())(scope);
这意味着它首先将其添加到DOM中,然后对其进行编译
在底线中,您将其描述为
这是一个没有完成ng repeat的模板(包括ng repeat之后
(待完成)