angular - ng2-smart-table自定义渲染组件

标签 angular ng2-smart-table

我尝试在 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 { }

有人看到这个问题吗?为什么他工厂认为该组件未定义。

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

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 模块来修复它

关于angular - ng2-smart-table自定义渲染组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46224695/

相关文章:

html - 单独组件 Angular2 中的备用 div 样式

Angular - 智能表格不会填满

angular - Ng2-智能表 : Use drop-downs or date pickers in inline editing

typescript - 使用 AngularFire 和 Firestore 使用 Ng2 智能表显示嵌套对象

ng2-smart-table - 如何在行单击时将 View 模式从 View 更改为编辑?

node.js - 如何在可视代码中调试 Angular 7 库

Angular 4 Output() 带下拉菜单

angularjs - Angular 2通过服务器API加载数据: data.切片错误

javascript - 如何以 Angular 修复 404(未找到)

javascript - 使用 Electron 截取桌面截图