DEV Community


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

mustapha profile image
Mustapha Aouas Author

Hi David,

Both ways are absolutely valid and there’s not a better way to do it as both methods have their pros and cons. Also I disagree on the maintainability, if not I find using @input way more maintainable on large projects.

If you are building components for your own usage you can use contentChild as you mentioned. If you are building components for other people (other teams At your company for example), using input is more explicit and more flexible (the templateRef doesn’t have to be in the projection area for example).
For instance ng-zorro (ant design library) use this approach.

At the end of the day, it depends on what you want to achieve, one method is more declarative, the other is more imperative.

idlevandal profile image
David Allen

Thank you so much for the reply and sharing your knowledge. I've been using your guitar app as well, it's awesome!!!