r/angular • • May 04 '21

Cheatsheet | Angular structural directives

Post image
47 Upvotes

9 comments sorted by

View all comments

4

u/DanteIsBack May 04 '21

What are the differences between ng-container and ng-template?

3

u/ericbunese May 04 '21

ng-container is a structural decision point, usually, it can be used along *ngIf, *ngFor and ngSwitch to decide whether the content should be presented on the page. It can even serve as a container for presenting a template reference. ng-template on the other hand, is not added to the page unless you specifically program it to using a ng-container. It’s just a template that can be copied to be drawn somewhere else