Skip to content

Instantly share code, notes, and snippets.

@lrkwz
Created June 18, 2016 23:33
Show Gist options
  • Save lrkwz/96b0ffadb2b5365436f3f5d1afb6ce19 to your computer and use it in GitHub Desktop.
Save lrkwz/96b0ffadb2b5365436f3f5d1afb6ce19 to your computer and use it in GitHub Desktop.
Fontawesome iconify
angular
.module('myapp', [...])
.filter('iconify', ['$sce', function($sce){
return function(input, type){
var iconType = 'fa-file-o';
if( input ){
if( input.startsWith('image/')){
iconType = 'fa-file-pdf-o';
} else if (input == 'application/pdf') {
iconType = 'fa-file-image-o';
}
} else {
input = '';
}
var out = '<i class="' + input +' fa fa-2x '+iconType+'" aria-hidden="true"></i>';
return $sce.trustAs( type || 'html', out);
}
}])
.run(run);
@lrkwz
Copy link
Author

lrkwz commented Jun 18, 2016

Include fontawsome using

bower install --save fontawesome

then drop somewhere in your template

<span ng-bind-html="item.mimeType|iconify">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment