Class IgxIconService

Ignite UI for Angular Icon Service -

The Ignite UI Icon Service makes it easy for developers to include custom SVG images and use them with IgxIconComponent. In addition it could be used to associate a custom class to be applied on IgxIconComponent according to given font-family.

Example:

this.iconService.registerFamilyAlias('material', 'material-icons');
this.iconService.addSvgIcon('aruba', '/assets/svg/country_flags/aruba.svg', 'svg-flags');

Hierarchy

  • IgxIconService

Constructors

constructor

  • new IgxIconService(_sanitizer: DomSanitizer, _document: any): IgxIconService

Properties

iconLoaded

iconLoaded: Observable<IgxIconLoadedEvent>

Observable that emits when an icon is successfully loaded through a HTTP request.

@example
this.service.iconLoaded.subscribe((ev: IgxIconLoadedEvent) => ...);

Accessors

defaultFamily

  • get defaultFamily(): string
  • set defaultFamily(className: string): void

Methods

addSvgIcon

  • addSvgIcon(name: string, url: string, family?: string): void
  • Adds an SVG image to the cache. SVG source is an url.

      this.iconService.addSvgIcon('aruba', '/assets/svg/country_flags/aruba.svg', 'svg-flags');

    Parameters

    • name: string
    • url: string
    • Default value family: string = ""

    Returns void

addSvgIconFromText

  • addSvgIconFromText(name: string, iconText: string, family?: string): void
  • Adds an SVG image to the cache. SVG source is its text.

      this.iconService.addSvgIcon('simple', '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200">
      <path d="M74 74h54v54H74" /></svg>', 'svg-flags');

    Parameters

    • name: string
    • iconText: string
    • Default value family: string = ""

    Returns void

familyClassName

  • familyClassName(alias: string): string

getSvgIconKey

  • getSvgIconKey(name: string, family?: string): string

isSvgIconCached

  • isSvgIconCached(name: string, family?: string): boolean

registerFamilyAlias

  • registerFamilyAlias(alias: string, className?: string): this
  • Registers a custom class to be applied to IgxIconComponent for a given font-family.

      this.iconService.registerFamilyAlias('material', 'material-icons');

    Parameters

    • alias: string
    • Default value className: string = alias

    Returns this