Standalone directive that inlines SVG assets into the host element.
Classes
- NgxSvgDirective
Standalone directive bound to the
[ngx-decaf-svg]attribute selector. On initialisation it resolves the SVG asset path from the[ngx-decaf-svg]input binding or, as a fallback, the host element's nativesrcattribute. Once a non-empty path is determined it callsNgxMediaService.loadSvgObserver, which performs the HTTP request viaHttpClientand injects the SVG markup directly into the host element's DOM, enabling full CSS styling of the inlined SVG.
Members
ElementRef
# static DecafTooltipDirective#element
Obtained via Angular's inject(ElementRef). Provides access to the native
element forwarded to NgxMediaService.loadSvgObserver as the injection target,
and used as a fallback source for the src attribute when path is not set.
Reference to the host DOM element into which the SVG will be injected.
ElementRef
# static NgxSvgDirective#element
Obtained via Angular's inject(ElementRef). Provides access to the native
element forwarded to NgxMediaService.loadSvgObserver as the injection target,
and used as a fallback source for the src attribute when path is not set.
Reference to the host DOM element into which the SVG will be injected.
HttpClient
# static NgxSvgDirective#http
Injected HttpClient passed directly to
NgxMediaService.loadSvgObserver so the service can issue the GET request for
the SVG file without managing its own HTTP dependency.
HTTP client instance forwarded to the media service for the SVG fetch.
NgxMediaService
# static NgxSvgDirective#mediaService
Injected NgxMediaService instance used by ngOnInit to perform the
HTTP request and inject the resulting SVG markup into the host element's DOM.
Service responsible for fetching and inlining the SVG markup.
string
# static NgxSvgDirective#path
Bound via the [ngx-decaf-svg] attribute. When empty or not provided, the
directive falls back to reading the host element's native src attribute during
ngOnInit.
URL or asset path to the SVG file to inline.
ElementRef
# static element
Obtained via Angular's inject(ElementRef). Provides access to the native
element forwarded to NgxMediaService.loadSvgObserver as the injection target,
and used as a fallback source for the src attribute when path is not set.
Reference to the host DOM element into which the SVG will be injected.
ElementRef
# static element
Obtained via Angular's inject(ElementRef). Provides access to the native
element forwarded to NgxMediaService.loadSvgObserver as the injection target,
and used as a fallback source for the src attribute when path is not set.
Reference to the host DOM element into which the SVG will be injected.
HttpClient
# static http
Injected HttpClient passed directly to
NgxMediaService.loadSvgObserver so the service can issue the GET request for
the SVG file without managing its own HTTP dependency.
HTTP client instance forwarded to the media service for the SVG fetch.
NgxMediaService
# static mediaService
Injected NgxMediaService instance used by ngOnInit to perform the
HTTP request and inject the resulting SVG markup into the host element's DOM.
Service responsible for fetching and inlining the SVG markup.
string
# static path
Bound via the [ngx-decaf-svg] attribute. When empty or not provided, the
directive falls back to reading the host element's native src attribute during
ngOnInit.
URL or asset path to the SVG file to inline.
Methods
# static NgxSvgDirective#ngOnInit() → {void}
Trims path and, when empty, falls back to the host element's src attribute.
When a valid path is found, delegates to NgxMediaService.loadSvgObserver to
fetch the file and inject the SVG markup into the host element.
Resolves the SVG path and triggers the inline load.
void