DEV Community


Discussion on: Angular: Build more dynamic components with ngTemplateOutlet 🎭

avoerman profile image
Alex Voerman

Maybe worth mentioning since it's a relatively undocumented feature, but the slotting feature that comes with the transculsion api could be helpful for the 2nd scenario:

<app-card [title]="title">
  <h2 title>Hello there</h2>
  <p>i'm an awesome card.</p>

<div class="card">
  <header [select]="title"></header>

Although it doesn't cover the union-type check in your example.

mustapha profile image
Mustapha Aouas Author

Yes, the slotting feature is great an could help a lot depending on the scenario. When it comes to overloading templates and building reusable components i find the code to be easier to maintain with templateOutlet, but that’s only my two cents.

Thanks for sharing πŸ˜ƒ