How to import an Enum
I was missing the export keyword:
export enum EntityStatus {
New = 0,
Active = 1,
Archived = 2,
Trashed = 3,
Deleted = 4
}
Then it worked as expected.
You will get the same Cannot read property 'Foo' of undefined.
runtime error when you happen to define your Enum in one of the TypeScript Declaration files (*.d.ts
) as these files does not get transpired into JavaScript.
More details with a sample app can be found here.
Kindly try this. It works for me
enums.ts
export enum Category {Cricket,Tennis,Golf,Badminton}
and in required .ts file import like the way given below:
import {Category} from './enums'