I'd like to extend credit to Matan Zohar for the replacement trick. For further info, see my blog.
Creates a reusable SVG component out of an external SVG file. This lets you control your SVGs using CSS.
More specifically, you will be able to change the fill color of the SVG, meaning you can change its color via CSS.
- AngularJS v1.3
- Previous versions might work too, but haven't been tested.
Download from here
npm install --save ng-reusable-svg
bower install ngReusableSvg
-
Add
ngReusableSvg.js
to your main file (index.html). -
Set
ngReusableSvg
as a dependency in your modulevar myApp = angular.module('myApp', ['ngReusableSvg'])
-
Add
oa-reusable-svg
onto an<object>
tag:<object oa-reusable-svg id="my-svg" data="my_icon.svg" type="image/svg+xml" class="svg-class" height="30" width="30"> </object>
-
Important! Make sure your SVG file itself does not specify its own height & width, otherwise this will not work properly.
-
ngClick - an action to be performed when the SVG image is clicked.
-
ngClass - an action to be performed to determine the class.
-
notifyReady - a boolean (needs to be initialized as false) that will be set to true when the switch has been performed. Useful if you need to know when the image is ready, for instance, when cloning the element.
-
float - Accepts only "false" value that turns off the default "float: left;" to the element.