it's a compilation issue, $sce service doesn't work out of the box when you render dynamic content that needs compilation.
you can resolve this by creating your own directive that force a compile.
app.directive('dynamic', function ($compile) {
return {
restrict: 'A',
replace: true,
link: function (scope, ele, attrs) {
scope.$watch(attrs.dynamic, function(html) {
ele.html(html);
$compile(ele.contents())(scope);
});
}
};
})
$scope.trustedContent = function(){
return $sce.trustAsHtml('<span ng-class="getIconColor('+ myColor +')">');
}
<div ng-bind-html="trustedContent()" dynamic> </div>
Rendering directives within $sce.trustAsHtml
http://plnkr.co/edit/3CewDscih8diAo4mMSwJ?p=preview