Why is this Angular standalone component inside NgTemplate no longer rendered properly?

338 views Asked by At

I have just converted a working module architecture to standalone components. Basically, one component has a template outlet. Another component has an NgTemplate which is passed in to the template outlet. This still works fine for the static HTML inside the NgTemplate. However, there is another standalone template inside the NgTemplate which is no longer rendered properly:

<ng-template>
 <p>This is rendered</p>
 <app-todo></app-todo> <!-- this is not rendered properly anymore -->
</ng-template>

Rendering

Any clues would be great.

1

There are 1 answers

0
Matthieu Riegler On BEST ANSWER

When using standalone: true you need to explicitly import the components used in your template.

@Component({
 selector: 'my-cmp',
 imports [TodoComponent, ... ],
 ...
})
export class MyComponent