V
V
Vladimir2021-10-10 09:53:45
Angular
Vladimir, 2021-10-10 09:53:45

Why is ngTemplateOutlet not working?

Hello. I'm studying the projection of content and ran into a problem, the attribute is not perceived. I searched where it can be imported from, googled what could be the problem, but I have no idea, BrowserModule is connected, you can't import it from @angular/common.

app.component.html

<app-header>

    <div *ngIf="true" [id]="1">
        <ng-container [ngTemplateOutlet]="content.templateRef"></ng-container>
    </div>

</app-header>


header.component.html

<header>
    <ng-template appExampleZippyContent>
        It depends on what you do with it.
    </ng-template>


<!--    <app-logo [_name]="name" (name)="setName($event)"></app-logo>-->
</header>


Directive

import {Directive, TemplateRef} from "@angular/core";

@Directive({
    selector: '[appExampleZippyContent]'
})
export class ZippyContentDirective {
    constructor(public templateRef: TemplateRef<unknown>) {}
}


I do everything according to the documentation

Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question