CompileElement constructor
CompileElement(
- CompileElement? parent,
- CompileView? view,
- int? nodeIndex,
- NodeReference renderNode,
- TemplateAst? sourceAst,
- CompileDirectiveMetadata? component,
- List<
CompileDirectiveMetadata> _directives, - List<
ProviderAst> _resolvedProvidersArray, - bool hasViewContainer,
- bool hasEmbeddedView,
- List<
ReferenceAst> references, { - Expression? componentView,
- bool hasTemplateRefQuery = false,
- bool isHtmlElement = false,
Implementation
CompileElement(
CompileElement? parent,
CompileView? view,
int? nodeIndex,
NodeReference renderNode,
this.sourceAst,
this.component,
this._directives,
this._resolvedProvidersArray,
this.hasViewContainer,
this.hasEmbeddedView,
List<ReferenceAst> references, {
this.componentView,
this.hasTemplateRefQuery = false,
this.isHtmlElement = false,
}) : super(parent, view, nodeIndex, renderNode) {
_providers = ProviderResolver(this, parent?._providers);
if (references.isNotEmpty) {
for (final reference in references) {
final token = reference.value;
referenceTokens[reference.name] = token;
_publishesTemplateRef = _publishesTemplateRef ||
token != null && token.equalsTo(Identifiers.TemplateRefToken);
}
}
// Create new ElementRef(_el_#) expression and provide as instance.
elementRef = o
.importExpr(Identifiers.ElementRef)
.instantiate([renderNode.toReadExpr()]);
_providers.add(Identifiers.ElementRefToken, elementRef);
_providers.add(Identifiers.ElementToken, renderNode.toReadExpr());
_providers.add(Identifiers.HtmlElementToken, renderNode.toReadExpr());
var readInjectorExpr =
o.InvokeMemberMethodExpr('injector', [o.literal(this.nodeIndex)]);
_providers.add(Identifiers.InjectorToken, readInjectorExpr);
if (hasViewContainer || hasEmbeddedView) {
appViewContainer = view!.createViewContainer(
renderNode,
nodeIndex!,
!hasViewContainer,
isRootElement ? null : parent!.nodeIndex,
);
_providers.add(Identifiers.ViewContainerToken, appViewContainer!);
}
// This logic was copied from the setter for `componentView`, which was
// removed when `componentView` was made final (as there was no need for it
// to ever be reassigned).
if (componentView != null) {
final indexCount = component!.template!.ngContentSelectors.length;
for (var i = 0; i < indexCount; i++) {
contentNodesByNgContentIndex.add([]);
}
}
}