Why Dashboard?
Dashboards are very common thing in the world of wed apps, also it involves creation of dynamic components - thing i want to investigate.
Here i have gathered some useful links about Dynamic Components In Angular, so you can learn a lot of stuff about Dynamic Components:
- dynamic components guide(angular)
- dynamically creating components(Netanel Basal blog)
- dynamically creating components with angular 2(rangle.io)
Scenario
Lets say we wanna build some application which has user customized dashboard. Dashboard should display 3 kind of widgets as default, but use can decide which widgets will be displayed.
How To Create Dynamic Component
For creating dynamic component with current angular (version 5.2.0-beta.1 ) all you need to know about is ComponentFactoryResolver - angular factory that allows you to add components dynamically
Once you get ComponentFactoryResolver injected into constructor of dymanic component
constructor(private resolver: ComponentFactoryResolver) {}
You can add any component which registered inside entryComponents property
Please see my first stackblitz embedd here:
No comments:
Post a Comment