StaticInjectorErro(AppModule) [ScrollableView -> Table]: table 没有提供者

StaticInjectorErro(AppModule) [ScrollableView -> Table]: No provider for table

我正在为我的项目使用 primeng 组件。我想使用 table 组件,但我不得不对 table 组件的模板进行一些更改。所以我制作了一个扩展 primeng Table class 的新组件。然后有一些关于 ptablebodypscrollableview classes 的错误,我发现这两个组件没有在 primeng TableModule 中声明和导出,所以我将它们添加到 declarationsexports 文件中的数组 node_modules/primeng/components/table/table.js。在那之后有这个错误:

这是我的自定义 table 组件的代码:table.component.ts

import {Component, ElementRef,  NgZone} from '@angular/core';
    import { CommonModule } from '@angular/common';
    import {Table , TableService } from 'primeng/components/table/table';
    import { DomHandler } from 'primeng/components/dom/domhandler';
    import { ObjectUtils } from 'primeng/components/utils/objectutils';
    import { Subject, Subscription } from 'rxjs';
@Component({
    selector: 'app-custom-table',
    template: `
        <div #container [ngStyle]="style" [class]="styleClass"
            [ngClass]="{'ui-table ui-widget': true, 'ui-table-responsive': responsive, 'ui-table-resizable': resizableColumns,
                'ui-table-resizable-fit': (resizableColumns && columnResizeMode === 'fit'),
                'ui-table-hoverable-rows': (rowHover||selectionMode), 'ui-table-auto-layout': autoLayout}">
            <div class="ui-table-loading ui-widget-overlay" *ngIf="loading"></div>
            <div class="ui-table-loading-content" *ngIf="loading">
                <i [class]="'ui-table-loading-icon pi-spin ' + loadingIcon"></i>
            </div>
            <div *ngIf="captionTemplate" class="ui-table-caption ui-widget-header">
                <ng-container *ngTemplateOutlet="captionTemplate"></ng-container>
            </div>
            <p-paginator [rows]="rows" [first]="first" [totalRecords]="totalRecords" [pageLinkSize]="pageLinks" styleClass="ui-paginator-top" [alwaysShow]="alwaysShowPaginator"
                (onPageChange)="onPageChange($event)" [rowsPerPageOptions]="rowsPerPageOptions" *ngIf="paginator && (paginatorPosition === 'top' || paginatorPosition =='both')"
                [templateLeft]="paginatorLeftTemplate" [templateRight]="paginatorRightTemplate" [dropdownAppendTo]="paginatorDropdownAppendTo"></p-paginator>

            <div class="ui-table-wrapper" *ngIf="!scrollable">
                <table #table [ngClass]="tableStyleClass" [ngStyle]="tableStyle">
                    <ng-container *ngTemplateOutlet="colGroupTemplate; context {$implicit: columns}"></ng-container>
                    <thead class="ui-table-thead">
                        <ng-container *ngTemplateOutlet="headerTemplate; context: {$implicit: columns}"></ng-container>
                    </thead>
                    <tfoot class="ui-table-tfoot">
                        <ng-container *ngTemplateOutlet="footerTemplate; context {$implicit: columns}"></ng-container>
                    </tfoot>
                    <tbody class="ui-table-tbody" [pTableBody]="columns" [pTableBodyTemplate]="bodyTemplate"></tbody>
                </table>
            </div>

            <div class="ui-table-scrollable-wrapper" *ngIf="scrollable">
               <div class="ui-table-scrollable-view ui-table-frozen-view" *ngIf="frozenColumns||frozenBodyTemplate" [pScrollableView]="frozenColumns" [frozen]="true" [ngStyle]="{width: frozenWidth}" [scrollHeight]="scrollHeight"></div>
               <div class="ui-table-scrollable-view" [pScrollableView]="columns" [frozen]="false" [scrollHeight]="scrollHeight" [ngStyle]="{left: frozenWidth, width: 'calc(100% - '+frozenWidth+')'}"></div>
            </div>

            <app-custom-paginator [rows]="rows" [first]="first" [totalRecords]="totalRecords" [pageLinkSize]="pageLinks" styleClass="ui-paginator-bottom" [alwaysShow]="alwaysShowPaginator"
                (onPageChange)="onPageChange($event)" [rowsPerPageOptions]="rowsPerPageOptions" *ngIf="paginator && (paginatorPosition === 'bottom' || paginatorPosition =='both')"
                [templateLeft]="paginatorLeftTemplate" [templateRight]="paginatorRightTemplate" [dropdownAppendTo]="paginatorDropdownAppendTo"></app-custom-paginator>
            <div *ngIf="summaryTemplate" class="ui-table-summary ui-widget-header">
                <ng-container *ngTemplateOutlet="summaryTemplate"></ng-container>
            </div>

            <div #resizeHelper class="ui-column-resizer-helper ui-state-highlight" style="display:none" *ngIf="resizableColumns"></div>

            <span #reorderIndicatorUp class="pi pi-arrow-down ui-table-reorder-indicator-up" style="display:none" *ngIf="reorderableColumns"></span>
            <span #reorderIndicatorDown class="pi pi-arrow-up ui-table-reorder-indicator-down" style="display:none" *ngIf="reorderableColumns"></span>
        </div>
    `,
    providers: [DomHandler, ObjectUtils, TableService]
})
export class CustomTableComponent extends Table{

    constructor(public el: ElementRef, 
        public domHandler: DomHandler, 
        public objectUtils: ObjectUtils, 
        public zone: NgZone, 
        public tableService: TableService) {
            super(el , domHandler . objectUtils , zone, tableService);
        }

}

这里是错误

ERROR Error: StaticInjectorError(AppModule)[ScrollableView -> Table]: Static InjectorError(Platform: core)[ScrollableView -> Table]: NullInjectorEro: No Provider for Table! ...

ERROR Error: StaticInjectorError(AppModule)[TableBody -> Table]: Static InjectorError(Platform: core)[TableBody -> Table]: NullInjectorEro: No Provider for Table! ...

你知道我该如何解决这个问题吗?

我刚刚解决了它。 我应该将 table 添加到供应商数组。