0
votes

I have a requirement for adding icons dynamically to the rows of a ngx-datatable in my Angular 4 code.

Just to give a brief of what I'm trying to achieve: One column of my ngx-datatable would contain a Boolean value, either true or false, which is of course, returned by a service. In place of true I need to display a glyphicon-ok and on the other hand, in place of false I need to display a glyphicon-remove.

I searched all over the internet but can't find a proper way for doing so. Any suggestions anyone?

1

1 Answers

0
votes

You can use <ng-template> with button and icon as follows

 <ngx-datatable-column>
   <ng-template let-row="row" ngx-datatable-cell-template>
    <button *ngIf="row.query" md-icon-button mdTooltip="Expand/Collapse Row"
                              (click)="toggleSessionExpandRow(row, 'query')">
                           <i></i>
    </button>
    <span>{{ row.pid }}</span>
</ng-template>
</ngx-datatable-column>