Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Custom Components Templates

Custom Components Templates

It is an often scenario when you building one simple component, with the required functionality, and then these component consumers requesting support for more and more UI changes.

So what's the best way to customize components with Angular?
What are ThemplateRefs and how we can you the ngTemplateOutlet to let our consumers full control our components?

Join me for a session and find out how to create your own generic component template

Eliran Eliassy

June 22, 2020
Tweet

More Decks by Eliran Eliassy

Other Decks in Technology

Transcript

  1. e-square.io — Founder & CEO @ e-square.io — GDE for

    Angular & Web Technologies — Writer for AngularInDepth — Community leader About mySelf
  2. e-square.io The Story… • You = UI architect in a

    big company, creating components library • Every component used by more than 1 team • You’ve just asked to create a new imgae swiper component
  3. e-square.io Requirements • Should get images sources as an Input

    • Should support trackpad swiping • Should have Next and Prev buttons to navigate in slides
  4. e-square.io Things gets complicated… • Consumer 2 really likes your

    swiper • He really want you use it, but not for images • He also want to control the swiper navigation with his custom events • New “UI requirements” will probably keep coming…
  5. e-square.io Let’s re-think… • Adding Inputs with ngIf’s to control

    the templates will do the work, but also will ruin your neat component
  6. e-square.io Let’s summarise • Using ngTemplateOutlet can give our components

    consumers full control over the templates without adding redundant Input’s or ngIf’s • ngTemplateOutletContext can expose any inner component functionality • If you building UI library - use it almost everywhere!