简体   繁体   中英

How to pass external variables to ngx-datatable-column?

I'm trying to get access of an external variable "distance" inside of a cell template. Therefore I'm looking for a way to tell the template the variable like this.

I know that the code below can't work, but how can I achieve something like this? Unfortunately, it is no option to enhance the objects of "filteredSkaterlist" with the objects of "distaneList"

<ngx-datatable [rows]="filteredList">
    <ng-container *ngFor="let distance of distaneList">
        <ngx-datatable-column name="distance">
            <ng-template let-row="row" let-distance="distance" ngx-datatable-cell-template>
                {{ row | json }}
                {{ distance | json }}
            </ng-template>
        </ngx-datatable-column>
    </ng-container>
</ngx-datatable>

Well, I found a solution by myself:

<ngx-datatable-column *ngFor="let distance of distancelist" name="distance" prop="distance">
    <ng-template let-column="column" ngx-datatable-header-template>
        {{ distance.name }}
    </ng-template>

    <ng-template let-skater="row" ngx-datatable-cell-template>
        {{ skater.name }}
        {{ distance.name }}
    </ng-template>
</ngx-datatable-column>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM