【问题标题】:ngTemplateOutlet not working in mat-tablengTemplateOutlet 在 mat-table 中不起作用
【发布时间】:2019-01-08 18:10:46
【问题描述】:

我正在尝试按照here 提到的解决方案以角度重用一些 html 组件。在我的场景中,我在一页中有 2 个垫表,其中包含一些常见的列。我正在尝试将公共列放在模板中,并在我的 mat-table 定义中引用该模板。但它没有编译,角度无法在模板中找到列定义。 Here is the stackblitz 链接。请告知我错过了什么。

【问题讨论】:

    标签: angular ng-template mat-table


    【解决方案1】:

    尝试使用 ViewChild:

    @ViewChild('CommonColumns') CommonColumns: TemplateRef<any>;
    

    把它放在你的 ts 文件中。您正在尝试使用 [ngTemplateOutlet] 引用 ts 文件中不存在的内容。

    【讨论】:

    猜你喜欢
    • 2018-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-01
    • 2020-01-25
    • 1970-01-01
    • 2018-07-04
    相关资源
    最近更新 更多