代码之家  ›  专栏  ›  技术社区  ›  Bogdan

素数p-表动态标题

  •  1
  • Bogdan  · 技术社区  · 6 年前

    我是安格拉尔和普雷明的新手。我不知道如何将表标题作为变量传递:

    <p-table [value]="userSrv.items"  [title]="table.title">
            <ng-template pTemplate="caption" let-title>
                {{title}}
            </ng-template>
            <ng-template pTemplate="header">
                <tr>
                    <th>Name</th>
                    <th>Email</th>
                </tr>
            </ng-template>
            <ng-template pTemplate="body" let-item>
                <tr>
                    <td>{{item.fullName}}</td>
                    <td>{{item.email}}</td>
                </tr>
            </ng-template>
    </p-table>
    

    ngTemplate='caption' (或其他模板)在ngOnInit组件方法上。

    1 回复  |  直到 6 年前
        1
  •  1
  •   Antikhippe    6 年前

    没有必要定义这样的东西 [title]="table.title" let-title .

    <ng-template pTemplate="caption">
        {{title}}
    </ng-template>
    

    见工作 StackBlitz