Skip to content

Instantly share code, notes, and snippets.

@mikemunsie
Forked from joaoneto/icon-fill.js
Last active August 29, 2015 14:12
Show Gist options
  • Save mikemunsie/3184005d8afdaec6563e to your computer and use it in GitHub Desktop.
Save mikemunsie/3184005d8afdaec6563e to your computer and use it in GitHub Desktop.
Fixed load issue and icon color display by using JQLite.
/**
* Markup
* <md-icon icon-fill="red" icon="'/img/icons/test.svg'" style="width: 32px; height: 32px;"></md-icon>
*/
angular.module('material.components.icon.extra', [
'ngMaterial'
])
.directive('iconFill', function () {
return {
restrict: 'A',
link: function(scope, element, attr) {
var object = angular.element(element[0].children[0]);
if(angular.isDefined(attr.iconFill)) {
object.load(object.attr("icon"), false, function () {
object.find("svg").css("fill", attr.iconFill);
});
}
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment