import { Directive , Input , TemplateRef , ViewContainerRef } from "@angular/core" ; import { CONFIGURABLE_ENUM_CONFIG_PREFIX , ConfigurableEnumConfig , } from "../configurable-enum.interface" ; import { ConfigService } from "../../config/config.service" ; /**
 * Enumerate over all  ConfigurableEnumConfig values for the given enum config id.
 *
 * Works similar to `*ngFor`:
 * `<div *appConfigurableEnum="let item of 'interaction-type'"></div>`
 * will create one div for each option defined in the config for "enum:interaction-type".
  @ Directive ( { selector : "[appConfigurableEnum]" , } ) export class ConfigurableEnumDirective { param enumConfigId @ Input ( ) set appConfigurableEnumOf ( enumConfigId ) { if ( ! enumConfigId . startsWith ( CONFIGURABLE_ENUM_CONFIG_PREFIX ) ) { enumConfigId = CONFIGURABLE_ENUM_CONFIG_PREFIX + enumConfigId ; } const options = this . configService . getConfig < ConfigurableEnumConfig > ( enumConfigId ) ; for ( const item of options ) { this . viewContainerRef . createEmbeddedView ( this . templateRef , { $implicit : item , } ) ; } } param templateRef param viewContainerRef param configService constructor ( private templateRef , private viewContainerRef , private configService ) { } }