Enums in TypeScript are numbers at runtime, so message.type
will be 0
, 1
, 2
or 3
.
To get the string value, you need to pass that number into the enum as an index:
Type[0] // "Info"
So, in your example, you’ll need to do this:
Type[message.type] // "Info" when message.type is 0
More Related Contents:
- typescript anonymous object with variable based label value
- How do I return the response from an Observable/http/async call in angular?
- How to load external scripts dynamically in Angular?
- Property ‘…’ has no initializer and is not definitely assigned in the constructor
- Angular 2: How to detect changes in an array? (@input property)
- Angular: Can’t find Promise, Map, Set and Iterator
- Angular 2 router event listener
- Angular2 component’s “this” is undefined when executing callback function
- Angular 2: TypeError: l_thing0 is undefined in [{{thing.title}} in AppComponent@4:44]
- Load existing components dynamically Angular 2 Final Release
- Angular 5 Scroll to top on every Route click
- Prevent IE11 caching GET call in Angular 2
- Nested arrays in Angular 2 reactive forms?
- Angular: In which lifecycle hook is input data available to the Component
- angular 4+ assign @Input for ngComponentOutlet dynamically created component
- Angular 4 Filter Search Custom Pipe
- Correct way Provide DomSanitizer to Component with Angular 2 RC6
- Angular 2 typescript invoke javascript function
- Whats the difference between using a class and interface?
- What does Angular 2 hashtags in template mean?
- How to loop over object properties with ngFor in Angular
- Angular 6: ERROR TypeError: “… is not a function” – but it is
- Angular interceptor exclude specific urls
- How can I loop through enum values for display in radio buttons? [duplicate]
- TypeScript enum to object array
- How to iterate using ngFor loop Map containing key as string and values as map iteration
- TypeScript TS7015: Element implicitly has an ‘any’ type because index expression is not of type ‘number’
- Google Sign-In for Websites and Angular 2 using Typescript
- Filter Array in Array by date between 2 dates
- binding data to angular checkbox