Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
ng-inline-svg
Advanced tools
Formerly called ng2-inline-svg
Angular directive for inserting an SVG inline within an element, allowing for easily styling
with CSS like fill: currentColor;
.
This is based on md-icon, except this is meant purely for inserting SVG files within an element, without the extra things like font icons.
npm install --save ng-inline-svg
Add HttpClientModule
and InlineSVGModule
to your list of module imports:
import { HttpClientModule } from '@angular/common/http';
import { InlineSVGModule } from 'ng-inline-svg';
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, HttpClientModule, InlineSVGModule],
bootstrap: [AppComponent]
})
class AppModule {}
The base URL will be automatically fetched based on your <base>
tag. If you want to configure the base URL manually, you can use the forRoot
function:
InlineSVGModule.forRoot({ baseUrl: 'https://mysite.com/myapp/' })
If you want to configure the base URL later, use the service's function:
import { SVGCacheService } from 'ng-inline-svg';
class YourComponent {
constructor(svgService: SVGCacheService) {
svgService.setBaseUrl({ baseUrl: 'https://mysite.com/myapp/' });
}
}
You can then use the directive in your templates:
@Component({
selector: 'app',
template: `
<div class="my-icon" aria-label="My icon" [inlineSVG]="'/img/image.svg'"></div>
`
})
export class AppComponent {
}
The SVG file (if found) will be inserted inside the element with the [inlineSVG]
directive. Support for icons using the symbol
method is also supported (e.g. [inlineSVG]="'#shape-id'"
).
Property name | Type | Default | Description |
---|---|---|---|
cacheSVG | boolean | true | Caches the SVG based on the absolute URL. Cache only persists for the (sessional) lifetime of the page. |
prepend | boolean | false | Inserts before the first child instead of appending, overwrites replaceContents |
replaceContents | boolean | true | Replaces the contents of the element with the SVG instead of just appending it to its children. |
injectComponent | boolean | false | Injects an <inline-svg> component containing the SVG inside the element with the directive. |
removeSVGAttributes | string[] | An array of attribute names to remove from all child elements within the SVG. | |
forceEvalStyles | boolean | false | Forces embeded style tags' contents to be evaluated (for IE 11). |
evalScripts | 'always' , 'once' , 'none' | 'always' | Whether to evaluate embedded scripts in the loaded SVG files. |
fallbackImgUrl | string | URL for a regular image to be displayed as a fallback if the SVG fails to load. |
Property name | Callback arguments | Description |
---|---|---|
onSVGInserted | e: SVGElement | Emits the SVGElement post-insertion. |
onSVGFailed | e: any | Emits when there is some error (e.g. embed SVG not supported, fetch failed, etc.) |
FAQs
[DEPRECATED] Angular directive for inserting an SVG inline within an element.
The npm package ng-inline-svg receives a total of 10,483 weekly downloads. As such, ng-inline-svg popularity was classified as popular.
We found that ng-inline-svg demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.