I have this enum (I\'m using TypeScript) :
export enum CountryCodeEnum {
France = 1,
Belgium = 2
}
I would like to build a
As of Angular 6.1 and above you can use the built-in KeyValuePipe
like below (pasted from angular.io docs).
I'm assuming that an enum contains human friendly readable strings of course :)
@Component({
selector: 'keyvalue-pipe',
template: `
Object
{{item.key}}:{{item.value}}
Map
{{item.key}}:{{item.value}}
`
})
export class KeyValuePipeComponent {
object: {[key: number]: string} = {2: 'foo', 1: 'bar'};
map = new Map([[2, 'foo'], [1, 'bar']]);
}