Angular content projection (with ng-content) is really useful to create reusable component. But have you ever wanted to use the ng-content inside a loop ? This will not work in angular, because angular does not support multiple ng-content tag with the same select attribute.

So let’s try to do this…

I love content projection in angular but I had a case where I wanted to load an object before showing the ng-content. So I wrapped my ng-content with a *ngIf directive.

Unfortunately I had some error because my projected component was instantiated even if my showContent variable was set…

Benjamin Maisonneuve

Freelance web developer using angular and angular material since v2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store