File

projects/i-components/src/lib/directives/ribbonGroupItemsDirective.directive.ts

Description

This is a directive in charge of get component instance since it was not possible to read InjectionToken on structural directive

Metadata

Selector [wmRibbonItemInstance]

Index

Properties

Constructor

constructor(component: RibbonComponentData | null)

Creates an instance of RibbonInstanceDirective.

Parameters :
Name Type Optional
component RibbonComponentData | null No

Properties

Public component
Type : any

Component instance

import {
  ComponentRef,
  Directive,
  ElementRef,
  Inject,
  InjectionToken,
  Input,
  Optional,
  TemplateRef,
  ViewContainerRef,
} from '@angular/core';

/**
 * Injection token used to access to components
 *
 * @export
 * @class InjectionToken
 */
export const D_COMPATIBLE_COMPONENT = new InjectionToken<RibbonComponentData>(
  'D_COMPATIBLE_COMPONENT'
);

/**
 * RibbonGroupDirective
 *
 * @export
 * @class RibbonGroupDirective
 */
@Directive({
  selector: '[wmRibbonGroupItem]',
})
export class RibbonGroupDirective {
  /**
   * Creates an instance of RibbonGroupDirective.
   *
   * @param {TemplateRef<any>} template
   * @memberof RibbonGroupDirective
   */
  constructor(public template: TemplateRef<any>) {}
}

/**
 * This is a directive in charge of get component instance since it was not possible to read InjectionToken on structural directive
 *
 * @export
 * @class RibbonInstanceDirective
 */
@Directive({
  selector: '[wmRibbonItemInstance]',
})
export class RibbonInstanceDirective {
  /**
   * Component instance
   *
   * @type {*}
   * @memberof RibbonInstanceDirective
   */
  public component: any;

  /**
   * Creates an instance of RibbonInstanceDirective.
   *
   * @param {(RibbonComponentData | null)} component
   * @memberof RibbonInstanceDirective
   */
  constructor(
    @Optional()
    @Inject(D_COMPATIBLE_COMPONENT)
    component: RibbonComponentData | null
  ) {
    this.component = component;
  }
}

/**
 * Interface to be implemented on all RibbonGroupComponents
 *
 * @export
 * @interface RibbonComponentData
 */
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface RibbonComponentData {}

result-matching ""

    No results matching ""