diff --git a/src/cdk/table/text-column.ts b/src/cdk/table/text-column.ts index a65abffe799..aa37a38997c 100644 --- a/src/cdk/table/text-column.ts +++ b/src/cdk/table/text-column.ts @@ -78,7 +78,10 @@ export class CdkTextColumn implements OnDestroy, OnInit { } set name(name: string) { this._name = name; - this.columnDef.name = name; + + // With Ivy, inputs can be initialized before static query results are + // available. In that case, we defer the synchronization until "ngOnInit" fires. + this._syncColumnDefName(); } _name: string; @@ -127,6 +130,8 @@ export class CdkTextColumn implements OnDestroy, OnInit { } ngOnInit() { + this._syncColumnDefName(); + if (this.headerText === undefined) { this.headerText = this._createDefaultHeaderText(); } @@ -165,4 +170,11 @@ export class CdkTextColumn implements OnDestroy, OnInit { return this.name[0].toUpperCase() + this.name.slice(1); } + + /** Synchronizes the column definition name with the text column name. */ + private _syncColumnDefName() { + if (this.columnDef) { + this.columnDef.name = this.name; + } + } }