I have this enum (I\'m using TypeScript) :
export enum CountryCodeEnum {
France = 1,
Belgium = 2
}
I would like to build a
This is the best option which you can apply without any pipes or extra code.
import { Component } from '@angular/core';
enum AgentStatus {
available =1 ,
busy = 2,
away = 3,
offline = 0
}
@Component({
selector: 'my-app',
template: `
Choose Value
You entered {{AgentStatus[myValue]}}
`
})
export class AppComponent {
options : string[];
myValue: AgentStatus;
AgentStatus : typeof AgentStatus = AgentStatus;
ngOnInit() {
var x = AgentStatus;
var options = Object.keys(AgentStatus);
this.options = options.slice(options.length / 2);
}
parseValue(value : string) {
this.myValue = AgentStatus[value];
}
}