Have access to the values of an enum in a html page


In a .ts file, I have a method that returns an array of enumerations to me.
I would like to have access to the values of a my table in an input in my HTML page. Can you help me please


Can you be more specific?
About your input for example?
Let’s say your enumeration is countries or colors…
You want to show them in a select box? Here is the topic on that: http://aurelia.io/docs/binding/selects#introduction
Or you want them to be lookup values in autocomplete?
Or do you want an array of checkboxes? A topic for checkboxes: http://aurelia.io/docs/binding/checkboxes


As @Alexander-Taran said you should explain in more detail but maybe you work with enum type in typescript if yes you should read the following article.


@Pirlo972 in your view model assign enum type to a field. This will allow you to use this field in HTML so it looks like you’re using types. There is also this article http://www.foursails.co/blog/template-constants/ if you want a more generic solution


I ran into a similar issue and found this question. I would like to declare an enum and also use that enum inside my view like so, but this doesn’t work:

// menu.ts
enum Menus {
  mainMenu = 'mainMenu',
  subMenu = 'subMenu',
export class Menu{
  currentMenu = Menus.mainMenu;
  goto(subMenu: Menus){ this.currentMenu = subMenu; }

// menu.html
  <nav class="${currentMenu === Menus.mainMenu ? 'js-is-current-menu' : ''}"></nav>


Use export enum - ts will preserve it then and won’t replace with inline constants. Also in your VM - Menus = Menus;