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