visitNgContent method

  1. @override
void visitNgContent(
  1. NgContentAst ast,
  2. CompileElement parent
)
override

Implementation

@override
void visitNgContent(NgContentAst ast, CompileElement parent) {
  _view.projectNodesIntoElement(parent, ast.index, ast.ngContentIndex);
  final reference = ast.reference;
  if (reference != null) {
    final provider = _view.createNgContentRefProvider(ast.index);
    final providerAst = ProviderAst(
      provider.token!,
      false,
      [provider],
      ProviderAstType.Builtin,
      ast.sourceSpan,
      eager: true,
    );
    var compileElement = CompileElement(
        parent,
        _view,
        ast.index,
        NodeReference.ngContent(_view.storage, ast.index),
        ast,
        null,
        [],
        [providerAst],
        false,
        false,
        [reference]);

    _view.nodes.add(compileElement);

    // Binds reference in <ng-content> to ViewComponent.
    _beforeChildren(compileElement);
  }
}