I am using Angular2 and Typscript. I have an enum:
export enum Role {
ServiceAdmin, CompanyAdmin, Foreman, AgentForeman,
CrewMember, AgentCrewMembe
I have the enum:
export enum FileCategory {
passport = 'Multipass',
agreement = 'Personal agreement',
contract = 'Contract',
photo = 'Self photos',
other = 'Other'
}
In the component ts file:
export class MyBestComponent implements OnInit {
fileCategory = FileCategory;
// returns keys of enum
fileKeys(): Array {
const keys = Object.keys(this.fileCategory);
return keys;
}
// returns values of enum
fileVals(): Array {
const keys = Object.keys(this.fileCategory);
return keys.map(el => Object(this.fileCategory)[el]);
}
In the HTML template display these enum's values and keys:
{{cat}}
{{cat}}