AiA 264: ngTemplateOutlets with Stephen Cooper
In this episode of Adventures in Angular the panel interviews Stephen Cooper about his recent talk at Angular Connect. His talk was about ngTemplateOutlets. Stephen answers the questions of the panel about ngTemplateOutlets and explains how and when to use them. He starts by explaining the difference between component outlets and template outlets.
Aaron Frost, Frosty, asks Stephen to walk through how to make a ngTemplate and explain what it is useful for. The panel considers the various use cases they would use this for. Frosty wonders why he would use a ngTemplateOutlet instead of a bunch of ngIfs. Stephen explains when it would be wise to use ngIfs and when it would be better to use ngTemplateOutlets.
The panel discusses ngComponentOutlets, Stephen explains how they relate to ngTemplateOutlets and how they give you another level to reusing components. He overviews the best way to use ngComponentOutlets and warns listeners of the tricky parts.
Stephen shares the best times to use ngTemplateOutlets and overviews some of the common use cases he has seen for them. He explains that they are very useful when creating shareable components or repeating similar chunks of code in a component. He shares some resources to help listeners get started.
- Aaron Frost
- Alyssa Nicoll
- Brian Love
- Shai Reznik
- Stephen Cooper
Adventures in Angular is produced by DevChat.TV in partnership with Hero Devs
"The MaxCoders Guide to Finding Your Dream Developer Job" by Charles Max Wood will be out on November 20th on Amazon. Get your copy on that date only for $2.99.
- ngTemplateOutlet: The secret to customisation | Stephen Cooper
- Advanced Angular: Implementing a Reusable Autocomplete Component
- Being back in the USA
- Zelda: Breath of the Wild
- Mr. Milks
- Destiny 2:Shadowkeep
- Garrett Reisman
- Visiting museums near you
What is the difference between component outlets and template outlets?
They are basically the same thing only with component outlets you pass components through and with template outlets you pass templates through.
What is the point of a ngTemplate?
It is a nice way to define a set of templates and save time by reusing it in a component template throughout your application and pass in context objects.
When should you use a ngIf instead of a ngTemplateOutlet?
When customization and other features are small ngIfs work great, but if you have more than a few options ngTemplateOutlets would be the better choice.
What is the tricky part of ngComponentOutlets?
The input and output bindings.