Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
angular-svg-icon
Advanced tools
Angular 2+ component for inlining SVGs allowing them to be easily styled with CSS.
The angular-svg-icon is an Angular 2+ service and component that provides a means to inline SVG images to allow for them to be easily styled by CSS and code.
The service provides an icon registery that loads and caches a svg indexed by
its url. The component is responsible for displaying the svg. After getting the
svg from the registry it clones the SVGElement
and the svg to the component's
inner HTML.
A working demo shows solution in action.
$ npm i angular-svg-icon --save
The angular-svg-icon should work as-is with webpack/angular-cli. Just add
the AngularSvgIconModule
.
import { AngularSvgIconModule } from 'angular-svg-icon';
@NgModule({
imports: [ AngularSvgIconModule ],
...
})
export class AppModule {}
Basic usage is:
<svg-icon src="path/to/icon.svg"></svg-icon>
An example of styling the svg:
<svg-icon src="images/eye.svg" style="fill:green;width:90px;"></svg-icon>
The svg-icon is an Angular 2 component that allows for the continuation of the AngularJS method for easily inlining SVGs explained by Ben Markowitz and others. Including the SVG source inline allows for the graphic to be easily styled by CSS.
The technique made use of ng-include to inline the svg source into the document. Angular 2, however, drops the support of ng-include, so this is my work-around method.
Note: The icon component from angular/material2 used to have a direct means to load svg similar to this, but this functionality was removed because of security concerns.
MIT
FAQs
Angular 18 component and service for inlining SVGs allowing them to be easily styled with CSS.
The npm package angular-svg-icon receives a total of 67,770 weekly downloads. As such, angular-svg-icon popularity was classified as popular.
We found that angular-svg-icon demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.