Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ng2-inline-svg

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng2-inline-svg

Angular 2 directive for inserting an SVG inline within an element.

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by60%
Maintainers
1
Weekly downloads
 
Created
Source

ng2-inline-svg

NPM

Demo

Angular 2 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.

Installation

npm install --save ng2-inline-svg

Usage

Add InlineSVGModule to your list of module imports:

import { InlineSVGModule } from 'ng2-inline-svg';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, InlineSVGModule],
  bootstrap: [AppComponent]
})
class AppModule {}

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.

Options

Inputs
Property nameTypeDefaultDescription
cacheSVGbooleantrueCaches the SVG based on the absolute URL. Cache only persists for the (sessional) lifetime of the page.
prependbooleanfalseInserts before the first child instead of appending, overwrites replaceContents
replaceContentsbooleantrueReplaces the contents of the element with the SVG instead of just appending it to its children.
removeSVGAttributesstring[]An array of attribute names to remove from all child elements within the SVG.
Outputs
Property nameCallback argumentsDescription
onSVGInsertede: SVGElementEmits the SVGElement post-insertion.

Keywords

FAQs

Package last updated on 21 Nov 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc