Reputation: 1711
Imagine the following string enum, which is defined in a component.ts:
export enum SortType {
Date = 'date',
}
I want to use the value of the enum in the corresponding HTML-component: <th mat-sort-header=??? >
Something like that: <th mat-sort-header='SortType.Date' >
.
Upvotes: 1
Views: 298
Reputation: 12960
Assign the value of imported Enum in a class property.
import { SortType } from '.....path'
@component({data})
export class YourComponent {
sortEnum = SortType;
}
Use in your HTML
<th mat-sort-header="{{sortEnum.Date}}" >.
Upvotes: 2
Reputation: 1227
In ts create a class property as public sortEnum=SortType and access in html
public sortEnum=SortType
Upvotes: 1