1

I have the following enum in my Angular 2 app:

export enum DataProviderDefinitionType {
    JDBC = <any> "JDBC",
    CSV = <any> "CSV",
    EXCEL = <any> "EXCEL"  }

I require to have an array containing all values of this enum. This should be programmed in a generic way. Recently I do have:

export namespace DataProviderDefinitionType {

export function obtainAllValues(): DataProviderDefinitionType[] {
     var result: DataProviderDefinitionType[] = [];
    result.push(DataProviderDefinitionType.JDBC);
    result.push(DataProviderDefinitionType.CSV);
    result.push(DataProviderDefinitionType.EXCEL);

    return result;
}

This works, however is not a satisfying solution.

Any advice how to make that more generic?

Michael
  • 1,692
  • 1
  • 17
  • 19
Emdee
  • 1,689
  • 5
  • 22
  • 35
  • 3
    Possible duplicate of [How to programmatically enumerate an enum type in Typescript 0.9.5?](http://stackoverflow.com/questions/21293063/how-to-programmatically-enumerate-an-enum-type-in-typescript-0-9-5) – Matthias247 Nov 11 '16 at 15:11
  • Duplicate of http://stackoverflow.com/questions/21293063/how-to-programmatically-enumerate-an-enum-type-in-typescript-0-9-5 and http://stackoverflow.com/questions/18111657/how-does-one-get-the-names-of-typescript-enum-entries – Matthias247 Nov 11 '16 at 15:12

0 Answers0