Reputation: 21617
This is my filter in Angular, I've only shown the snippet of it the application. This works in one controller but when I try to use it in another one it doesn't.
What I mean by is doesn't work - it doesnt render inside the DOM. It renders inside the tags though.
AngularJS:
<h2 ng-bind-html="'{{ answer.title }}' | to_trusted"></h2>
Example Rendered
<h2 ng-bind-html="'0-60 minutes per week' | to_trusted" class="ng-binding"></h2>
AngularJS Filter
.filter('to_trusted', ['$sce', function($sce){
return function(text) {
return $sce.trustAsHtml(text);
};
}])
Have I missed something out by accident here?
Upvotes: 0
Views: 420
Reputation: 17064
I think what will make it work for you is this syntax, since answer.title
is text already:
<h2 ng-bind-html="answer.title | to_trusted"></h2>
Upvotes: 1