如何在Angular 6中从外部应用程序动态添加组件?

时间:2018-08-10 13:10:55

标签: angular angular6 angular-dynamic-components

我的Angular6应用程序外部有一个JSON文件,我想在运行时读取该JSON文件并在应用程序中附加组件。

就像我要得到的

response:[{html:"<dynamic-component></dynamic-component>",component:"
import { Component, OnInit } from '@angular/core';
@Component({
  selector: 'dynamic-component',
  template: '<span>Hello from dynamic component</span>'
})
export class DynamicComponent implements OnInit {
  constructor() { }

  ngOnInit() {
  
  }

}"
}];

请提出建议,无论如何,在Angular6中,我都可以实现这种类型的动态组件加载器。

0 个答案:

没有答案