在Dynmaicaly在angular7中创建的模块中使用时,第三方库ngx-daterangepicker-material抛出静态注射器错误。

时间:2019-07-29 15:08:13

标签: angular ngx-daterangepicker-material

我一直在我的应用程序中使用ngx-daterangepicker-material,并且在共享模块(Angular7应用程序)以及其他功能模块中使用时,它工作正常,但是在创建动态模块和组件时会出错。使用共享模块,因为我需要动态组件中共享模块中的其他内容。

ngAfterViewInit() {
  let mydata = '<div appMovableArea appDropzone (drop)="move(currentBox, 
  dropzone1)" class="dropzone" style="width:50%; height:50%"></div>'


  const template = mydata;

  const tmpCmp = Component({template: template})(class {
  });
  const tmpModule = NgModule({declarations: [ tmpCmp],
                            imports: 
  [SharedModule,NgxDaterangepickerMd.forRoot()]})(class {
  });

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

如何清除引发的第三方错误。enter image description here

在调试的同时,我也看到它失败了     var cmpRef = f.create(_this._injector,[],null,_this._m);

0 个答案:

没有答案