angular2-injection

ng2 - dynamically creating a component based on a template

自闭症网瘾萝莉.ら 提交于 2019-11-26 09:01:55
问题 I\'ve been looking at the Angular 2 APIs for ComponentResolver and DynamicComponentResolver for creating dynamic components, but I have something different in mind than those APIs offer. Is there any way in NG2 to create a component based on a string of its class name? For example, Im building a configurable charts dashboard. Each user\'s layout is stored in the database, stating they want 2x line charts here, 3x bar charts there, etc. When I load this data as json it looks something like: