Reputation: 2725
Material Icons are working fine in my AngularJS app.
In my template.html :
<i class="material-icons"></i>
This works fine, the icon is displayed correctly.
But this code does not :
<div ng-repeat="x in pages">
current icon : {{x.icon}}
<br>
<i class="material-icons">{{x.icon}}</i>
</div>
where pages is defined in the controller :
$scope.pages = [
{icon: ""},
{icon: ""},
{icon: ""}
];
I can see the right value of {{x.icon}}.
Why does
<i class="material-icons">{{x.icon}}</i>
not work ?
Upvotes: 3
Views: 353
Reputation: 406
use ng-bind-html
and unsafe filter:
templat.html
<i class="material-icons" ng-bind-html="x.icon | unsafe "></i>
JS
app.filter('unsafe',function($sce){
return $sce.trustAsHtml
})
Upvotes: 2