Angular 如果添加导入,则不会呈现任何内容

Angular 如果添加导入,则不会呈现任何内容,angular,typescript,ngx-charts,Angular,Typescript,Ngx Charts,这是我的组件。ts: @Component({ selector: 'bancaComponent', template: ` <ng-container #dynamicTemplate></ng-container> ` }) export class BancaComponent implements AfterViewInit, OnInit { @ViewChild('dynamicTemp

这是我的组件。ts:

@Component({
  selector: 'bancaComponent',
  template: `
                <ng-container #dynamicTemplate></ng-container>
              `
})
export class BancaComponent implements AfterViewInit, OnInit {
  @ViewChild('dynamicTemplate', { read: ViewContainerRef, static: false }) dynamicTemplate;
  BarChartDataInput = [
    {
      "name": "Germany",
      "value": 40632,
      "extra": {
        "code": "de"
      }
    },
    {
      "name": "United States",
      "value": 50000,
      "extra": {
        "code": "us"
      }
    },
    {
      "name": "France",
      "value": 36745,
      "extra": {
        "code": "fr"
      }
    },
    {
      "name": "United Kingdom",
      "value": 36240,
      "extra": {
        "code": "uk"
      }
    },
    {
      "name": "Spain",
      "value": 33000,
      "extra": {
        "code": "es"
      }
    },
    {
      "name": "Italy",
      "value": 35800,
      "extra": {
        "code": "it"
      }
    }
  ];
  constructor(private _compiler: Compiler,
    private _injector: Injector,
    private _m: NgModuleRef<any>) {
  }

  ngAfterViewInit() {

    let myTemplateUrl = `<p>test</p>`;

    const tmpCmp = Component({
      moduleId: module.id, template: myTemplateUrl
    })(class {
    });
    const tmpModule = NgModule({imports: [NgxChartsModule, BrowserModule, CommonModule, BrowserAnimationsModule]
      , declarations: [tmpCmp] })(class {
    });

    this._compiler.compileModuleAndAllComponentsAsync(tmpModule)
      .then((factories) => {
        const f = factories.componentFactories[0];
        const cmpRef = f.create(this._injector, [], null, this._m);
        cmpRef.instance.name = 'dynamic';
        this.dynamicTemplate.insert(cmpRef.hostView);
      });
  }
  ngOnInit() {

  }
}
@组件({
选择器:“bancaComponent”,
模板:`
`
})
导出类BancComponent在ViewInit、OnInit之后实现{
@ViewChild('dynamicTemplate',{read:ViewContainerRef,static:false})dynamicTemplate;
BarChartDataInput=[
{
“名称”:“德国”,
“价值”:40632,
“额外”:{
“代码”:“de”
}
},
{
“名称”:“美国”,
“价值”:50000,
“额外”:{
“代码”:“美国”
}
},
{
“名称”:“法国”,
“价值”:36745,
“额外”:{
“代码”:“fr”
}
},
{
“名称”:“联合王国”,
“价值”:36240,
“额外”:{
“代码”:“英国”
}
},
{
“名称”:“西班牙”,
“价值”:33000,
“额外”:{
“代码”:“es”
}
},
{
“名称”:“意大利”,
“价值”:35800,
“额外”:{
“代码”:“it”
}
}
];
构造函数(私有编译器:编译器,
专用注射器:注射器,
私人(NgModuleRef){
}
ngAfterViewInit(){
让myTemplateUrl=`测试

`; 常量tmpCmp=组件({ moduleId:module.id,模板:myTemplateUrl })(类{ }); const tmpModule=NgModule({imports:[NgxChartsModule,BrowserModule,CommonModule,BrowserAnimationsModule] ,声明:[tmpCmp]})(类{ }); 此._compiler.compileModule和所有组件同步(tmpModule) .然后((工厂)=>{ 常数f=工厂。组件工厂[0]; const cmpRef=f.create(this.\u喷油器,[],null,this.\u m); cmpRef.instance.name='dynamic'; this.dynamicTemplate.insert(cmpRef.hostView); }); } 恩戈尼尼特(){ } }
我想呈现一个动态模板,其中包含ngx图表,但在ngx模块中,我需要添加ngx图表工作所需的导入,如果我删除导入数组,则会呈现普通标记,但在添加任何导入后,不会显示任何内容,控制台中也不会出现错误。我怎样才能解决这个问题