I want to create an AngularJs directive that will allow me to display a specific icon (from a folder that contains a lot of different icon) for a specific file, for example:
If myFile is an Html file we display icon_html.png, etc.
I saw this answer from Dayan Moreno Leon but he uses a CSS stylesheet to display the specific icon, I was searching something more generic.
Any advice or recommendations are welcome :)
Update, I tried this :
My directive :
myApp.directive("icon", function () {
return {
template: "<img ng-src='style/icon/files_type_icons_flat/PNG/icon_{{icon}}.png'/>",
replace: false,
scope: true,
compile: function (tElement, tAttrs) {
// this is link function
return function (scope) {
scope.icon = tAttrs.icon;
};
}
};
});
My view :
<tr ng-repeat="row in entities" >
<td>
<div icon="{{row.extension}}"></div> {{row[col.title]}}.{{row.extension}}
</td>
</tr>
Nothing worked :(
Many thanks.