父母组件的实例如何传递到子组件构造函数中



我正在尝试了解该表组件在Primeng中的工作方式。我对父母组件的实例是如何将其传递到子组件的构造函数的方式。

的构造函数。

这是表格组件中表组件的源。Primeng Table Source

因此,我的理解是表机构组件具有属性作为选择器。它从父(表(组件中传递在列和bodytemplate中。现在,我不明白的是,当parent组件(表(创建时是如何传递到它的实例。

表组件模板的片段

            <div class="ui-table-wrapper" *ngIf="!scrollable">
            <table #table [ngClass]="tableStyleClass" [ngStyle]="tableStyle">
                <ng-container *ngTemplateOutlet="colGroupTemplate; context {$implicit: columns}"></ng-container>
                <thead class="ui-table-thead">
                    <ng-container *ngTemplateOutlet="headerTemplate; context: {$implicit: columns}"></ng-container>
                </thead>
                <tfoot *ngIf="footerTemplate" class="ui-table-tfoot">
                    <ng-container *ngTemplateOutlet="footerTemplate; context {$implicit: columns}"></ng-container>
                </tfoot>
                <tbody class="ui-table-tbody" [pTableBody]="columns" [pTableBodyTemplate]="bodyTemplate"></tbody>
            </table>
        </div>

完整来源:github源

任何见解都将受到极大的赞赏。

属性[ptablebody]和[ptabledemtemplate]在父组件中已在TS文件中声明@Input。和"列"被绑定到具有相同名称的变量。

阅读有关输入和输出的一些信息

希望我有所帮助。

最新更新