Class

NgxSvgDirective

lib/directives/NgxSvgDirective~NgxSvgDirective()

Constructor

# new 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 native src attribute. Once a non-empty path is determined it calls NgxMediaService.loadSvgObserver, which performs the HTTP request via HttpClient and injects the SVG markup directly into the host element's DOM, enabling full CSS styling of the inlined SVG.

Angular directive that fetches an SVG file and inlines it into the host element.

Implements:
  • OnInit

View Source lib/directives/svg.directive.ts, line 19

Example
```html
<!-- Via directive binding -->
<div [ngx-decaf-svg]="'/assets/icons/logo.svg'"></div>

<!-- Fallback to src attribute -->
<img ngx-decaf-svg src="/assets/icons/arrow.svg" />
```