Open Closed

Angular - Enum - dropdown list #10576


User avatar
0
sserestyen created

Hi,

Using the commercial license with Angular frontend. For those dropdown lists where we get the list of items from the API we use the abp-lookup-select component.

Just wondering if there is a similar component for working with enum-s?

e.g. given below enum

import { mapEnumToOptions } from '@abp/ng.core';

export enum GeometryTypeEnum {
  None = 1,
  Point = 2,
  Line = 3,
  Polygon = 4,
  All = 5,
}

export const geometryTypeEnumOptions = mapEnumToOptions(GeometryTypeEnum);

Thanks.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Hi,

    ABP doesn't have a dedicated enum select component like abp-lookup-search. The standard approach is to use mapEnumToOptions combined with a regular HTML <select> element — this is exactly how ABP's own extensible form system handles enum dropdowns internally.

    Here's how you can use it:

    Component (TypeScript):

    import { mapEnumToOptions } from '@abp/ng.core';
    
    export enum GeometryTypeEnum {
      None = 1,
      Point = 2,
      Line = 3,
      Polygon = 4,
      All = 5,
    }
    
    // In your component class:
    geometryTypeOptions = mapEnumToOptions(GeometryTypeEnum);
    

    Template (HTML):

    <select class="form-select form-control" formControlName="geometryType">
      <option *ngFor="let option of geometryTypeOptions" [ngValue]="option.value">
        {{ option.key }}
      </option>
    </select>
    

    If you want to localize the enum display names, you can use the abpLocalization pipe:

    <option *ngFor="let option of geometryTypeOptions" [ngValue]="option.value">
      {{ '::Enum:GeometryType.' + option.key | abpLocalization }}
    </option>
    

    Then define the corresponding localization keys in your localization JSON files (e.g., Enum:GeometryType.None, Enum:GeometryType.Point, etc.).

    Thanks

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    sserestyen created

    Hi,

    That's great, thanks for providing the example.

    Thanks.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    : )

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.