ng-container is mentioned in Angular 2 documentation but there is no explanation how it works and what are use cases.
It is particularly mentioned in ng
The documentation (https://angular.io/guide/template-syntax#!#star-template) gives the following example. Say we have template code like this:
Before it will be rendered, it will be "de-sugared". That is, the asterix notation will be transcribed to the notation:
If 'currentHero' is truthy this will be rendered as
[...]
But what if you want an conditional output like this:
Title
text
.. and you don't want the output be wrapped in a container.
You could write the de-sugared version directly like so:
Title
text
And this will work fine. However, now we need ngIf to have brackets [] instead of an asterix *, and this is confusing (https://github.com/angular/angular.io/issues/2303)
For that reason a different notation was created, like so:
Title
text
Both versions will produce the same results (only the h1 and p tag will be rendered). The second one is preferred because you can use *ngIf like always.