angularkendo-gridkendo-angular-ui

angular 2+ and kendo angular add computed class


I want to add css class to my span element class="badge badge-danger"

<kendo-grid-column field="inactive" title="Enabled" width="20%">
    <ng-template kendoGridCellTemplate let-subType>
        <span [class]="'badge badge-' + subType.inactive ? 'danger' : 'primary'">123</span>
    </ng-template>
</kendo-grid-column>

But in result I have <span class="danger"

What am I doing wrong?


Solution

  • use parenthesizes

    [class]="'badge badge-' + (subType.inactive ? 'danger' : 'primary')"