diff --git a/projects/ngx-datatable/src/lib/components/body/body-cell.component.ts b/projects/ngx-datatable/src/lib/components/body/body-cell.component.ts index ecc48a985..fe7cfb605 100644 --- a/projects/ngx-datatable/src/lib/components/body/body-cell.component.ts +++ b/projects/ngx-datatable/src/lib/components/body/body-cell.component.ts @@ -76,7 +76,11 @@ import { AsyncPipe, NgTemplateOutlet } from '@angular/common'; } @if (!column.cellTemplate) { - + @if (column.bindAsUnsafeHtml) { + + } @else { + {{ value }} + } } @else { implements TableColumn, OnChanges { private columnChangesService = inject(ColumnChangesService); @Input() name: string; @Input() prop: TableColumnProp; + @Input({ transform: booleanAttribute }) bindAsUnsafeHtml?: boolean; @Input({ transform: booleanAttribute }) frozenLeft: boolean; @Input({ transform: booleanAttribute }) frozenRight: boolean; @Input({ transform: numberAttribute }) flexGrow: number; diff --git a/projects/ngx-datatable/src/lib/components/header/header-cell.component.ts b/projects/ngx-datatable/src/lib/components/header/header-cell.component.ts index ad534bf39..9be783394 100644 --- a/projects/ngx-datatable/src/lib/components/header/header-cell.component.ts +++ b/projects/ngx-datatable/src/lib/components/header/header-cell.component.ts @@ -47,7 +47,8 @@ import { NgTemplateOutlet } from '@angular/common'; } @else { - + + {{ name }} } diff --git a/projects/ngx-datatable/src/lib/types/table-column.type.ts b/projects/ngx-datatable/src/lib/types/table-column.type.ts index a8d1505a9..c4d636a64 100644 --- a/projects/ngx-datatable/src/lib/types/table-column.type.ts +++ b/projects/ngx-datatable/src/lib/types/table-column.type.ts @@ -119,6 +119,14 @@ export interface TableColumn { */ prop?: TableColumnProp; + /** + * By default, the property is bound using normal data binding `{{content}}`. + * If this property is set to true, the property will be bound as ``. + * + * **DANGER** If enabling this feature, make sure the source of the data is trusted. This can be a vector for HTML injection attacks. + */ + bindAsUnsafeHtml?: boolean; + /** * Cell template ref */