Dynamic Components, View Encapsulation and Deferrable Views (@defer)
Learn Dynamic Components, View Encapsulation and Deferrable Views (@defer) (Phase 10 · Advanced Angular (Essential), Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Dynamic components • A dynamic component is created at runtime rather than written in a template: dialogs, widgets chosen by configuration, dashboards, plugin systems. • Use ViewContainerRef.createComponent(Type) (returns a ComponentRef : set inputs with setInput() , subscribe to outputs, call destroy() ) or the declarative *ngComponentOutlet / NgComponentOutlet . • Load the component class lazily with import() to keep it out of the main bundle.