I have this code:
<span data-icon="{{table.addIcon || ''}}"></span>
That span creates an icon like this:
However, I want to give the developer using this directive, the possibility to define a new icon. It is working, however, the problem I have is that, supposing I have this:
$scope.table.addIcon = ""
Instead of creating the element
<span data-icon=""></span>
it will create it
<span data-icon="&#xe070;"></span>
Which will fail to add the icon, so instead of seeing this:
What I have is this:
Is there a way to avoid angular to convert the &
into &
?
Adding solution
Thanks to miensol the solution is this:
.directive("changeIcon", function() {
var d = document.createElement("div");
return {
restrict: "A",
link: function($scope, $ele, $attrs) {
log($attrs);
var originalIcon;
$scope.decodedIcon = $attrs.icon;
do {
originalIcon = $scope.decodedIcon;
d.innerHTML = originalIcon;
$scope.decodedIcon = d.firstChild.nodeValue;
} while (originalIcon != $scope.decodedIcon);
$attrs.$set('data-icon', $scope.decodedIcon);
}
}
})
And it is used like this:
<span change-icon icon="{{table.addIcon || ''}}"></span>