ng-reusable-svg v1.0.0
I'd like to extend credit to Matan Zohar for the replacement trick. For further info, see my blog.
ngReusableSvg - Reuse SVG Files with CSS Modifications
Creates a reusable SVG component out of an external SVG file. This lets you control your SVGs using CSS.
Dependencies
- AngularJS v1.3
How to get it?
Manual Download
Download from here
Bower
bower install ngReusableSvgUsage
Add
ngReusableSvg.jsto your main file (index.html).Set
ngReusableSvgas a dependency in your modulevar myApp = angular.module('myApp', ['ngReusableSvg'])Add
oa-reusable-svgonto 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.
ngReusableSvg Attributes
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.
9 years ago