angularangular-dynamic-components

Angular - How to pass / compose components into a generic component?


anyone know if it is possible to pass a component into another component? I am trying to promote code re-use in our company Dev team, but hitting some blockers . I have a Component for displaying Tabs, I want it to be generic and display what ever complex components I pass into it (components with inputs, outputs, events, implementing of components / directives etc).

eg. Maybe the Tabs will display a set of forms, or maybe a data-grid, or maybe a list, or any other component in the application. Is this possible? If so what is the best approach?

I have been looking at ng-template, ng-content, dynamic components, but not sure what the best approach is. Anyone have any suggestions?

(seems like this is easier in React, but we are restricted to Angular only)


Solution

  • Thanks @bertramp Looks like the NGTemplate solution is the best solution for this. Working on a POC to present to the team.