@@ -65,6 +65,7 @@ import {
6565 getTableUnknownColumnError ,
6666 getTableUnknownDataSourceError
6767} from './table-errors' ;
68+ import { CDK_TABLE } from './tokens' ;
6869
6970/** Interface used to provide an outlet for rows to be inserted into. */
7071export interface RowOutlet {
@@ -171,6 +172,7 @@ export interface RenderRow<T> {
171172 // declared elsewhere, they are checked when their declaration points are checked.
172173 // tslint:disable-next-line:validate-decorators
173174 changeDetection : ChangeDetectionStrategy . Default ,
175+ providers : [ { provide : CDK_TABLE , useExisting : CdkTable } ]
174176} )
175177export class CdkTable < T > implements AfterContentChecked , CollectionViewer , OnDestroy , OnInit {
176178 private _document : Document ;
@@ -752,7 +754,8 @@ export class CdkTable<T> implements AfterContentChecked, CollectionViewer, OnDes
752754 private _cacheColumnDefs ( ) {
753755 this . _columnDefsByName . clear ( ) ;
754756
755- const columnDefs = mergeQueryListAndSet ( this . _contentColumnDefs , this . _customColumnDefs ) ;
757+ const columnDefs = mergeArrayAndSet (
758+ this . _getOwnDefs ( this . _contentColumnDefs ) , this . _customColumnDefs ) ;
756759 columnDefs . forEach ( columnDef => {
757760 if ( this . _columnDefsByName . has ( columnDef . name ) ) {
758761 throw getTableDuplicateColumnNameError ( columnDef . name ) ;
@@ -763,11 +766,12 @@ export class CdkTable<T> implements AfterContentChecked, CollectionViewer, OnDes
763766
764767 /** Update the list of all available row definitions that can be used. */
765768 private _cacheRowDefs ( ) {
766- this . _headerRowDefs =
767- mergeQueryListAndSet ( this . _contentHeaderRowDefs , this . _customHeaderRowDefs ) ;
768- this . _footerRowDefs =
769- mergeQueryListAndSet ( this . _contentFooterRowDefs , this . _customFooterRowDefs ) ;
770- this . _rowDefs = mergeQueryListAndSet ( this . _contentRowDefs , this . _customRowDefs ) ;
769+ this . _headerRowDefs = mergeArrayAndSet (
770+ this . _getOwnDefs ( this . _contentHeaderRowDefs ) , this . _customHeaderRowDefs ) ;
771+ this . _footerRowDefs = mergeArrayAndSet (
772+ this . _getOwnDefs ( this . _contentFooterRowDefs ) , this . _customFooterRowDefs ) ;
773+ this . _rowDefs = mergeArrayAndSet (
774+ this . _getOwnDefs ( this . _contentRowDefs ) , this . _customRowDefs ) ;
771775
772776 // After all row definitions are determined, find the row definition to be considered default.
773777 const defaultRowDefs = this . _rowDefs . filter ( def => ! def . when ) ;
@@ -1084,10 +1088,15 @@ export class CdkTable<T> implements AfterContentChecked, CollectionViewer, OnDes
10841088 } ) ;
10851089 }
10861090
1091+ /** Filters definitions that belong to this table from a QueryList. */
1092+ private _getOwnDefs < I extends { _table ?: any } > ( items : QueryList < I > ) : I [ ] {
1093+ return items . filter ( item => ! item . _table || item . _table === this ) ;
1094+ }
1095+
10871096 static ngAcceptInputType_multiTemplateDataRows : BooleanInput ;
10881097}
10891098
1090- /** Utility function that gets a merged list of the entries in a QueryList and values of a Set. */
1091- function mergeQueryListAndSet < T > ( queryList : QueryList < T > , set : Set < T > ) : T [ ] {
1092- return queryList . toArray ( ) . concat ( Array . from ( set ) ) ;
1099+ /** Utility function that gets a merged list of the entries in an array and values of a Set. */
1100+ function mergeArrayAndSet < T > ( array : T [ ] , set : Set < T > ) : T [ ] {
1101+ return array . concat ( Array . from ( set ) ) ;
10931102}
0 commit comments