Skip to content

Instantly share code, notes, and snippets.

@smorcuend
Created August 9, 2015 10:03
Show Gist options
  • Save smorcuend/15da9fa27d44ce7f72bd to your computer and use it in GitHub Desktop.
Save smorcuend/15da9fa27d44ce7f72bd to your computer and use it in GitHub Desktop.
mdIconService from material-angularjs modified for support <use> tag on inline SVG sprites. (angular/material/src/components/icon/iconService.js)
/**
* Loads the reference of SVG element from icon set sprite using inline svg reference
*/
function Icon(el, config) {
if (el.tagName != 'svg') {
el = angular.element('<svg><use xlink:href="' + config.url + '#' + el.id + '"/></svg>')[0];
}
// Inject the namespace if not available...
if (!el.getAttribute('xmlns')) {
el.setAttribute('xmlns', "http://www.w3.org/2000/svg");
}
this.element = el;
this.config = config;
this.prepare();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment