diff --git a/src/cdk/table/table.spec.ts b/src/cdk/table/table.spec.ts
index 24158df04cb..8681027b36d 100644
--- a/src/cdk/table/table.spec.ts
+++ b/src/cdk/table/table.spec.ts
@@ -727,6 +727,14 @@ describe('CdkTable', () => {
['', '5', '6'],
]);
});
+
+ it('should not throw when multiTemplateDataRows is coerced from a static value', () => {
+ expect(() => {
+ setupTableTestApp(CoercedMultiTemplateDataRows);
+ fixture.detectChanges();
+ }).not.toThrow();
+ });
+
});
});
@@ -1625,6 +1633,59 @@ class WhenRowCdkTableApp {
}
}
+@Component({
+ template: `
+
+
+ Column A
+ {{row.a}}
+
+
+
+ Column B
+ {{row.b}}
+
+
+
+ Column C
+ {{row.c}}
+
+
+
+ Column C
+ index_1_special_row
+
+
+
+ Column C
+ c3_special_row
+
+
+
+ Index
+ {{index}}
+
+
+
+ Data Index
+ {{dataIndex}}
+
+
+
+ Render Index
+ {{renderIndex}}
+
+
+
+
+
+
+
+ `
+})
+class CoercedMultiTemplateDataRows extends WhenRowCdkTableApp {
+}
+
@Component({
template: `
diff --git a/src/cdk/table/table.ts b/src/cdk/table/table.ts
index 423a7623ae2..29f8277fe9d 100644
--- a/src/cdk/table/table.ts
+++ b/src/cdk/table/table.ts
@@ -346,7 +346,10 @@ export class CdkTable implements AfterContentChecked, CollectionViewer, OnDes
}
set multiTemplateDataRows(v: boolean) {
this._multiTemplateDataRows = coerceBooleanProperty(v);
- if (this._rowOutlet.viewContainer.length) {
+
+ // In Ivy if this value is set via a static attribute (e.g. ),
+ // this setter will be invoked before the row outlet has been defined hence the null check.
+ if (this._rowOutlet && this._rowOutlet.viewContainer.length) {
this._forceRenderDataRows();
}
}