Ng2-smart-table 自定义渲染组件

Ng2-smart-table custom Render component

我试图在我的 ng2-smart-table 中使用自定义渲染器组件,但出现以下错误。

No component factory found for undefined. Did you add it to @NgModule.entryComponents?
    at…, …}

奇怪的是组件说它未定义。

我的组件是这样的。

import { Component, OnInit, Input } from '@angular/core';
import { ChannelTableModeService } from '../../../../../../services/channel-table-mode.service';
import { ViewCell } from 'ng2-smart-table';

@Component({
  selector: 'app-channel-attribute-renderer',
  template: '{{renderValue}} --'
})
export class ChannelAttributeRendererComponent implements OnInit {

constructor() { }
  renderValue: string;
  @Input() value: string | number;
  @Input() rowData: any;
  ngOnInit() {
     this.renderValue =  '<' + this.value + '>';
  }

}

我还确保组件在模块中。

    @NgModule({
      imports: [
        Ng2SmartTableModule,
        CommonModule,
        ChannelProfileRoutingModule,    
        VeexCommonModule,
        TranslateModule,
        FormsModule
      ],
      entryComponents: [ChannelAttributeRendererComponent, PasswordRenderComponent],
      providers: [ChannelTableModeService],
      declarations: [ PasswordRenderComponent, ChannelProfileComponent, ChannelTableComponent, ServiceTypeComponent, ServiceGroupComponent, ChannelPlanEditorComponent, ChannelAttributeRendererComponent]
    })

export class ChannelProfileModule { }

所以有没有人看到这个问题。为什么他工厂认为组件未定义。

我的智能 table 的配置如下所示:

this.settings = { 
columns: {
  'Channel': {title: 'Channel'},
  'Channel Label': {title: 'Channel Name'},
  'Video': {title: 'Video', type: 'custom', renderComponent: 
PasswordRenderComponent}
}}

尝试从 github 获取 ng2-smart-table 的分发代码并替换 node_modules 目录中现有的 ng-smart-table 代码。

我也遇到过类似的问题,我通过替换分发

中的 ng-smart-table 模块来修复它

有相同的"No component factory found for undefined. Did you add it to @NgModule.entryComponents?" 我通过在列定义中将 "renderComponent" 更改为 "component" 来修复它。

我通过查看开发工具中的错误发现了这个,它试图从“.component”获取渲染组件,如果您使用 renderComponent