3

我有基本组件和基本指令:

@Component({
    selector: 'datatable',
    template: `<ng-content><ng-content>`
})
export class DatatableComponent {
    QueryList<DatatableColumn> columns;
}

@Directive({ selector: 'datatable-column' })
export class DatatableColumn { }

现在我想创建具有相同功能的扩展 DatatableComponent

@Component({
    selector: 'df-datatable',
    template: `<ng-content><ng-content>`
})
export class DFDatatableComponent extends DatatableComponent {
    QueryList<DFDatatableColumn> columns;
}
 @Directive({ selector: 'df-datatable-column' })
    export class DFDatatableColumn extends DatatableColumn  { }

我的问题是为什么这不起作用?

<df-datatable>
    <df-datatable-column>
    </df-datatable-column>
</df-datatable>

但这有效。如何从基类覆盖 QueryList?

<df-datatable>
    <datatable-column>
    </datatable-column>
</df-datatable>
4

0 回答 0