Member Junction
    Preparing search index...

    ControlValueAccessor double for <mj-dropdown> (MJDropdownComponent in @memberjunction/ng-ui-components). Registers NG_VALUE_ACCESSOR, so templates binding [(ngModel)] / formControlName to it compile and run (without a CVA, Angular throws NG01203).

    Mirrors the real inputs (Data, TextField, ValueField, Filterable, ValuePrimitive, Disabled, Placeholder, DefaultItem, plus the accessible-name passthroughs AriaLabel, AriaLabelledBy, InputId, AriaDescribedBy) and outputs (ValueChange, FilterChange).

    Keeping that mirror TRUE is the point, not tidiness: the DOM test environment sets errorOnUnknownProperties, so a consumer spec whose template binds [AriaLabel] on a stubbed dropdown throws NG0303 — and a static AriaLabel="…" attribute is worse, landing silently as a vacuous pass. The template renders an empty <select class="mj-dropdown">; specs that want to push a value through the form can set the select's value and dispatch change, or call the stub's CVA hooks directly. The last written value is exposed as value for assertions.

    Implements

    • ControlValueAccessor
    Index

    Constructors

    Properties

    AriaDescribedBy: string = ''
    AriaLabel: string = ''
    AriaLabelledBy: string = ''
    Data: string[] | Record<string, unknown>[] | readonly unknown[] | null = []
    DefaultItem: string | Record<string, unknown> | null = null
    Disabled: boolean = false
    Filterable: boolean = false
    FilterChange: EventEmitter<string> = ...
    InputId: string = ''
    Placeholder: string = 'Select...'
    TextField: string = ''
    value: unknown

    Last value written through the CVA (by the form or by user interaction).

    ValueChange: EventEmitter<string> = ...
    ValueField: string = ''
    ValuePrimitive: boolean = false

    Methods

    • Parameters

      • e: Event

      Returns void

    • Parameters

      • fn: (v: unknown) => void

        The callback function to register

      Returns void

      Registers a callback function that is called when the control's value changes in the UI.

      This method is called by the forms API on initialization to update the form model when values propagate from the view to the model.

      When implementing the registerOnChange method in your own value accessor, save the given function so your class calls it at the appropriate time.

      The following example stores the provided function as an internal method.

      registerOnChange(fn: (_: any) => void): void {
      this._onChange = fn;
      }

      When the value changes in the UI, call the registered function to allow the forms API to update itself:

      host: {
      '(change)': '_onChange($event.target.value)'
      }
    • Parameters

      • fn: () => void

        The callback function to register

      Returns void

      Registers a callback function that is called by the forms API on initialization to update the form model on blur.

      When implementing registerOnTouched in your own value accessor, save the given function so your class calls it when the control should be considered blurred or "touched".

      The following example stores the provided function as an internal method.

      registerOnTouched(fn: any): void {
      this._onTouched = fn;
      }

      On blur (or equivalent), your class should call the registered function to allow the forms API to update itself:

      host: {
      '(blur)': '_onTouched()'
      }
    • Parameters

      • v: unknown

      Returns void

      Writes a new value to the element.

      This method is called by the forms API to write to the view when programmatic changes from model to view are requested.

      The following example writes a value to the native DOM element.

      writeValue(value: any): void {
      this._renderer.setProperty(this._elementRef.nativeElement, 'value', value);
      }