I have a string based enum. Without changing the enum class, I need to display different strings on my modal. My obj contains the enum. My code is as follows:
ENUM:
export enum FooEnum {
ONE,
TWO,
THREE
}
HTML:
<select class="form-control"
type="text"
id="foo"
[(ngModel)]="obj.foo"
required
name="foo"
#foo="ngModel">
<option *ngFor="let foo of fooToList()" [ngValue]="foo">{{foo}}</option>
</select>
TypeScript:
fooToList(): Array<string> {
const keys = Object.keys(FooEnum);
return keys.slice(keys.length / 2);
}
I would like to view ONE as Un, TWO as Deux etc. Could you help me pretty please ?
Note: I included angular 2 also because 2 and 4 are highly similar.