0

I have created the following

export enum status {
    Draft = 1,
    Publish = 2,
    OnHold = 3,
    Completed = 4
}

In the ts file I declare it as follows and give it a default value

courseStatus: status = status.Draft;

However, in the HTML it gives me an ID when using the following:

<label [for]="'status'">{{courseStatus}}</label>

I tried adding another variable - but this still gives a number (as per link)

courseStatusValue: string = this.courseStatus.toString();

My API returns an ID. Its this ID I want to convert into an enum value.

Sniipe
  • 1,116
  • 3
  • 13
  • 28

1 Answers1

2

You need to change the values you assigned to the enum:

export enum status {
  Draft = 'Draft',
  Publish = 'Publish',
  OnHold = 'OnHold',
  Completed = 'Completed'
}
Maihan Nijat
  • 9,054
  • 11
  • 62
  • 110
  • hi Nijat, thanks for the input. I should have mentioned that the ID is what I get from the API. I use the enum to map it. – Sniipe Jun 11 '19 at 16:53